Thanks Jason! I believe the highlighter is the culprit here. Using highlighter with large fields will always incur performance considerations because it has to load the entire text, analyze it, and search it.
Here's a thread from a user with a similar problem as yours: Highlighting takes long time for large documents.
Here are some solutions to consider:
- Set
index_optionstooffsetsin the mapping. You'll have to reindex your data to try this solution. This will allow the defaultunifiedhighlighter to skip the analysis step. See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html#offsets-strategy for more info. - Set
term_vectortowith_position_offsetsin the mapping. This also requires reindexing. It will also increase the size of the index significantly. See the above links for more info on this option. - Use the fast vector highlighter by setting your highlighter
typetofvh. Use this option in conjunction with theterm_vectoroption. Comes with the same tradeoff. See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html#fast-vector-highlighter.