spring-data-examples
spring-data-examples copied to clipboard
Add Criteria example for nested Elasticsearch field
Relates to #591.
This PR adds a small Spring Data Elasticsearch example that demonstrates using
org.springframework.data.elasticsearch.core.query.Criteria against a nested field.
Changes:
- Introduced a
Talkdocument with aspeakersfield annotated as@Field(type = FieldType.Nested). - Added a simple
Speakervalue object. - Extended
ElasticsearchOperationsTestwithcriteriaQueryOnNestedSpeakers(), which:- saves one
Talkwith a nestedSpeaker, - saves another
Talkwithout speakers, - runs a
CriteriaQueryonspeakers.name, - asserts that only the matching talk is returned.
- saves one
Note:
On my local machine, the existing ElasticsearchOperationsTest fails to start the
ApplicationContext with a DataAccessResourceFailureException when initializing ConferenceRepository:
status: 400, [es/indices.exists] Expecting a response body, but none was sent.
This also happens on a clean checkout of main.
The changes in this PR are limited to adding the nested Criteria example and do not modify
the existing Elasticsearch configuration.