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.)