-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add support for field mappings containing dots #2502
Comments
I'll have to check if this might conflict with logic from spring-data-commons. |
details in the pull request description |
Hi @sothawo, thanks for the super fast fix! Can you explain how to differ between navigating the object graph using dot-notation vs direct field access for a dotted field? Thanks in advance! |
An ElasticsearchPersistentProperty has basically two names: the property name, which is the name used in the Java object, and the fieldname which is used in Elasticsearch. Normally they are the same, but there also could be a This fieldname is used at multiple places:
For Navigating the object graph is done by Spring Data on method name resolution and that needs the Java property names, so no conflict here, under the hood this builds a So the explicit field name is not used anywhere where object property trees are considered. What does not work of course is reading a nested structure coming from Elasticsearch into properties with dotted field names. For this you'd still need a nested object structure as well. |
Elastic supports storing values in fields which contain dots (e.g. "foo.bar") (see elastic/elasticsearch#15951).
Unfortunately, spring-data-elasticsearch does not seem to support mapping such dot-containing field values using the @Field-annotation.
Cause is following lines:
spring-data-elasticsearch/src/main/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverter.java
Lines 1422 to 1425 in d95af9f
The dot "." is (understandably) used for navigating the object graph.
Unfortunately the @Field-annotation does not allow overriding such behaviour (e.g. with a "navigateObjectGraphUsingDot=false" parameter or something similar).
Steps to reproduce:
Behaviour:
The value of the entity which is mapped with @field("foo.bar") is null and does not contain the actual value from the elastic document
The text was updated successfully, but these errors were encountered: