Elastic Search limit results

前端 未结 1 1938
抹茶落季
抹茶落季 2021-01-11 21:37

In MySQL I can do something like:

  SELECT id FROM table WHERE field = \'foo\' LIMIT 5

If the table has 10,000 rows, then this query is way

相关标签:
1条回答
  • 2021-01-11 21:41

    You are correct the query is being ran entirely. Queries by default return data sorted by score, so your query is going to score each document. The docs state that the fuzzy query isn't going to scale well, so might want to consider other queries.

    A limit filter might give you similar behavior to what your looking for.

    A limit filter limits the number of documents (per shard) to execute on

    To replicate mysql field='foo' try using a term filter. You should use filters when you don't care about scoring, they are faster and cache-able.

    0 讨论(0)
提交回复
热议问题