elasticsearchelasticsearch-rest-client

Elasticsearch Java HighLevelRestClient how to create not_analyzed index?


I am using the HighLevelRestClient 7.4.0 and I am curious how could I create a not_analyzed field when indexing documents using the Index API.

The problem is that I am trying to implement a movie search by title, and if I search for "matrix" it returns correct results, but if I search for "The matrix" it returns pretty much every movie that has "the" in the title (this was the case with matchQuery).

I changed to using termQuery, but now when I search for "matrix" it returns the correct results, when I search for "Matrix" it does not find anything and the same is the case with "the matrix".

I'm guessing the problem is that when I am indexing my documents, every text field is analyzed by default. How could I create not_analyzed indices?

Right now I am indexing movies by simply converting the data structure to Json with GSON.


Solution

  • Instead of matchQuery or termQuery, I had to use matchPhraseQuery in order to perform the search correctly.