Reputation: 433
We are using the spring-data-elasticsearch project to interface with our elasticsearch clusters, and have been using it now for around a year. Recently, we moved to elasticsearch 5.x (from 2.x) where we now have the "keyword" datatype.
I would like to index these keywords as lowercase values, which I know can be done with field normalizers. I can't find anywhere in the documentation or online where I can add a normalizer to a field through the annotation based mapping. E.g
@Field(type = FieldType.keyword, <some_other_param = some_normalizer>)
Is this something that can be done? I know that we can use JSON based mapping definitions as well, so I will fall back to that option if needed, but would like to be able to do it this way if possible.
Any help would be very appreciated!
Upvotes: 3
Views: 4253
Reputation: 645
Since the pull request of @xhaggi has been merged (spring-data-elasticsearch 3.1.3+ or Spring Boot 2.1.1), we have a normalizer
field in the @Field
annotation.
To use it, we need:
@Field
or an @InnerField
with params type = FieldType.Keyword, normalizer = "%NORMALIZER_NAME%"
@Setting(settingPath = "%PATH_TO_NORMALIZER_JSON_FILE%")
at the class level.%PATH_TO_NORMALIZER_JSON_FILE%
Upvotes: 5
Reputation: 51
There is a pending issue https://jira.spring.io/browse/DATAES-492 waiting for review.
Upvotes: 1
Reputation: 433
FYI, for anyone looking at this, the answer is there is not a way to do this at this time.
You can do this, however, by creating your mappings file as JSON in the Elasticsearch format. See: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html
You can then create that JSON file and link it to your Domain model with.
@Mapping(mappingPath = "some/path/mapping.json")
Note that this is not, in my experience, compatible with the provided annotation based mapping for fields.
Upvotes: 2