I am performing a search on a field that contains spaces, I would like it to not be analysed i.e. not be split to grams and be considered as a single entity. How do I do this in Java?
I am using the RESTHighLevelClient, version 7.4.
I am performing a search on a field that contains spaces, I would like it to not be analysed i.e. not be split to grams and be considered as a single entity. How do I do this in Java?
I am using the RESTHighLevelClient, version 7.4.
String is the datatype you are using in your java application. But in elasticsearch there are serveral string based field datatypes.
You should define a mapping for the documents you want to store in elasticsearch. For the field we're talking about, choose the keyword dataype in your mapping. Please be aware, that you cannot change the mapping of a field after documents with such one has been indexed. So try creating a new index and put the desired mapping using the mapping rest api for example. Afterwards, not earlier, index your data.
If you don't do that before indexing your documents, elasticsearch will guess the datatype for a field based on the values provided by the first document containing the field. Probably thats why your applications java string has been mapped to the text datatype in elasticsearch and searching on text differs form searches on a keyword field.
Cheers & happy new year!