0

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.

J. Loe
  • 201
  • 5
  • 14
  • 1
    if you create a not_analyzed(or keyword) field , you will only be able to search on entire text ex. "the matrix" , search "matrix" will not return anything. Instead pass "And" operator in match query. ex "query": { "match" : { "message" : { "query" : "this is a test", "operator" : "and" } } } You can also define minimum match percent – jaspreet chahal Oct 25 '19 at 10:08

1 Answers1

0

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

J. Loe
  • 201
  • 5
  • 14
  • one difference between match_phrase and match - In match_phrase order of words matters and in match it won't(just those tokens should be there) – jaspreet chahal Oct 25 '19 at 11:02