Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix scripted-and-runtime-fields.adoc #2902

Merged

Conversation

1autodidact
Copy link
Contributor

Entity birthDate field mismatch result in a mistake
1、Person record
@document(indexName = "persons")
public record Person(
@id
@nullable
String id,
@field(type = Text)
String lastName,
@field(type = Text)
String firstName,
@field(type = Keyword)
String gender,
@field(type = Date, format = DateFormat.basic_date)
LocalDate birthDate,
}
}
2、demo script
"""
Instant currentDate = Instant.ofEpochMilli(new Date().getTime());
Instant startDate = doc['birth-date'].value.toInstant();
return (ChronoUnit.DAYS.between(startDate, currentDate) / 365);
"""))
3、error log
[es/search] failed: [search_phase_execution_exception] all shards failed
co.elastic.clients.elasticsearch._types.ElasticsearchException: [es/search] failed: [search_phase_execution_exception] all shards failed

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 27, 2024
@sothawo sothawo merged commit 1d89054 into spring-projects:main Apr 27, 2024
1 check passed
@sothawo
Copy link
Collaborator

sothawo commented Apr 27, 2024

thanks for finding and fixing. This came from copying the code from my test program where I have defined a custom FieldNamingStrategy which maps the java name birthDate to the Elasticsearch field name birth-date, but of course in this example context the java property name must be used

@sothawo sothawo added the type: documentation A documentation update label Apr 27, 2024
@1autodidact 1autodidact deleted the Fix-scripted-and-runtime-fields-doc branch May 3, 2024 00:51
@1autodidact 1autodidact restored the Fix-scripted-and-runtime-fields-doc branch May 3, 2024 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged type: documentation A documentation update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants