Repository navigation
Unpack item with generated id - #153
evgeniycheban wants to merge 1 commit into
Conversation
aa69f7a to
220d233
Compare
f288f35 to
dcff31d
Compare
0966132 to
8292b6b
Compare
| precept = ReindexerPrecept.builder() | ||
| .fieldName(field.getName()) | ||
| .jsonPath(jsonPath) | ||
| .expression(Expression.field(field.getName()).apply(Expression.serial())) |
There was a problem hiding this comment.
field.getName() here and in the README example is not what the core uses. The left side of a precept must be an index name or a json path and field.getName() is the Java field name; it can differ from both, and the core then writes a different field.
fieldName is client-only: it is the map key and the property read for WHEN_NULL on an object. That property can be resolved from jsonPath through the item class, so fieldName does not need to be part of the API. I would also stop taking a complete field=func string and let the user pass the document path and the function as follows:
ReindexerPrecept updatedAtPrecept = ReindexerPrecept.builder()
.jsonPath("updatedAt")
.expression(Expression.now())
.applyStrategy(ApplyStrategy.ALWAYS)
.build();
registerPrecept should build the string sent to the core, using json path and target function.
There was a problem hiding this comment.
Done. Currently, the ReindexerNamespace applies the precept function to jsonPath, so the user only passes Expression.serial() or Expression.now() to the ReindexerPrecept.
The fieldName was renamed to fieldPath and is used to determine when the target field is null for Java objects, since relying only on jsonPath requires significant changes to BeanPropertyUtils.
| ``` | ||
|
|
||
| The `@Serial` annotation has the following strategies to apply the function: | ||
| - `WHEN_NULL` - when the field is null, use this strategy when the value must be generated only once. |
There was a problem hiding this comment.
I would suggest to mark WHEN_NULL as the recommended mode. And add note to ALWAYS policy: it's used as the default value due to compatibility reasons
a88f997 to
72754b9
Compare
Closes gh-152