elasticsearchmatchelkelasticsearch-analyzersterm-query

Disabling Elasticsearch search analyzer


Ps: For any answer if you could point me to the ES official documentation of which the answer is based on , I"ll really appreciate.


Solution

  • There are various scenarios where search analyzers come into the picture.

    Type of query:- Some queries are analyzed and some are not. queries which are analyzed like match query uses the same analyzer on the fields which were defined in the index mapping, while queries like term query don't use any search time analyzer. Read elasticsearch match vs term query

    Also snippet from official ES doc

    The match query is of type boolean. It means that the text provided is analyzed and the analysis process constructs a boolean query from the provided text.

    Type of fields:

    Text fields are analyzed by default and standard analyzer is the default analyzer for them, hence if you don't define an analyzer for text fields in index mapping and then make a match query, it would use the standard analyzer but if you use the term query then it would not use the search time analyzer.

    keyword fields then it would use the keyword analyzer, which is no-op analyzer, hence for match query on keyword fields it would use the keyword analyzer but is essentially like applying no search time analyzer.

    If you are using the match query or any other analyzed query, which uses the search time analyzers, then you can explicitly mention the search time analyzer as a keyword analyzer, which as I explained is a no-op analyzer, hence process of generating the tokens would be very efficient.