Spring Elastic Search Custom Field Names

I am new to Elastic Search and I am trying to implement it using Spring -data-elasticsearch.

I have fields with names such as "Transportation", "Phone Number" in our elastic search documents.

When I try to match the fields of the @Domain object with them, I do not get any data for them, because I could not successfully match these fields.

I tried to use @Field, I was disappointed, because it did not have the "name" property for matching with the custom field name.

Tried different variations of the GETTER function, none of them seem to display these fields.

I began to wonder if there is something here that I do not see here. What does the domain object field that should appear in a file called "Transport" look like?

Any help appreciated

+4
source share
1 answer

You can use your own name. Spring ES Data uses Jackson. That way you can use @JsonProperty("your_custom_name") to include a custom name in ES Mapping

eg:

 @Document(indexName = "your_index_name", type = "your_type_name") public class YourEntity { .... @JsonProperty("my_transportation") @Field(type = FieldType.String, searchAnalyzer = "standard", indexAnalyzer = "standard", store = true) // just for example private String myTransportation; .... } 

Note: Sorry, my English is bad .: D

+7
source

Source: https://habr.com/ru/post/1214592/


All Articles