Skip to content

Unpack item with generated id - #153

Open
evgeniycheban wants to merge 1 commit into
Restream:masterfrom
evgeniycheban:gh-152
Open

evgeniycheban wants to merge 1 commit into
Restream:masterfrom
evgeniycheban:gh-152

Conversation

@evgeniycheban

Copy link
Copy Markdown
Member

Closes gh-152

@evgeniycheban
evgeniycheban force-pushed the gh-152 branch 20 times, most recently from aa69f7a to 220d233 Compare October 20, 2026 00:54
@evgeniycheban
evgeniycheban force-pushed the gh-152 branch 9 times, most recently from f288f35 to dcff31d Compare October 20, 2026 20:41
@evgeniycheban
evgeniycheban force-pushed the gh-152 branch 16 times, most recently from 0966132 to 8292b6b Compare October 23, 2026 08:49
precept = ReindexerPrecept.builder()
.fieldName(field.getName())
.jsonPath(jsonPath)
.expression(Expression.field(field.getName()).apply(Expression.serial()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@evgeniycheban evgeniycheban Oct 24, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread README.md Outdated
```

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@evgeniycheban
evgeniycheban force-pushed the gh-152 branch 11 times, most recently from a88f997 to 72754b9 Compare October 25, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated id using serial() is not returned from modifyItem

2 participants