Limit the query size in elasticsearch

How can I limit the query to be executed (I mean the size) If the size is ,more size for example 10M than automatically the query has to be withdrawn/throw message

Not clear on the requirement
"Size" could mean:

  1. The number of documents in the index
  2. The number of documents that match the query
  3. The number of documents returned in the top-matching hits
  4. The number of documents analyzed in aggregations
  5. The number of terms in an aggregation e.g. top N authors.

What problem are you trying to avoid? Long-running queries? Irrelevant results? Memory issues?

Hi

To avoid Memory issues

Regards

Justin

Look at https://www.elastic.co/guide/en/elasticsearch/reference/2.1/search-request-from-size.html

Note that from + size can not be more than the index.max_result_window index setting which defaults to 10,000.