问题
- I'm working on the elasticsearch version 7.2 and i'm in the
process of improving the performance of ES calls made by the
application. - From what I read, if we haven't set a "search analyzer" , by default standard analyzer will be set.
- But in a case where a analyzer is not needed ,having an analyzer may affect performance. Do having all fields as "keywords" prevents this?
- Or is there any other way to disable this "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.
回答1:
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.
While if you use 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.
Meanwhile, I'll also look if we can explicitly disable the search time analyzers.
来源:https://stackoverflow.com/questions/56800073/disabling-elasticsearch-search-analyzer