Does adding field collapsing improve the query latency

In elastic-search, I am using phrase_prefix queries for my use case. Surprisingly, the query returns results much faster when adding collapse clause based on a field. This feels counter-intuitive to me since collapse should be doing additional processing on the results. Would anybody know the reasoning behind this / is the performance improvement due to collapse a known fact.

Sample query:
{ "timeout": "50ms", "size": 15, "query": { "multi_match": { "query": "random-text", "type": "phrase_prefix", "fields": [ "valueNames.shingle^40", "valueNames.exact^120", ] } }, "collapse": { "field": "keyName" } }

When I remove the collapse from keyName, the query returns results in twice as much time (and sometimes even worse.)

Have you tried to use the search profiler in Kibana? This allows you to see where your query time is spent.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.