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_options
tooffsets
in the mapping. You'll have to reindex your data to try this solution. This will allow the defaultunified
highlighter 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_vector
towith_position_offsets
in 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
type
tofvh
. Use this option in conjunction with theterm_vector
option. Comes with the same tradeoff. See https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-highlighting.html#fast-vector-highlighter.