loopback-connector-elastic-search icon indicating copy to clipboard operation
loopback-connector-elastic-search copied to clipboard

deleteByQuery should use a filter instead of a query for much better performance

Open mrfelton opened this issue 8 years ago • 0 comments

Currently, destroyAll issues a deleteByQuery operation with a query. Using a query causes ES to generate scores as part of the process and as a result has additional overhead.

As a general rule, filters should be used instead of queries: for binary yes/no searches for queries on exact values

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filters.html

As a general rule, queries should be used instead of filters: for full text search where the result depends on a relevance score

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html

Filters are very handy since they perform an order of magnitude better than plain queries since no scoring is performed and they are automatically cached.

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html

mrfelton avatar Sep 17 '15 06:09 mrfelton