ES query for huge set of records gives Out Of Memory error


In my application, i have huge set of records in ES. I am querying 500000
records and writing to a file, it is working fine. After the file has been
generated, I tried the same query. But the memory is not released because
of the first query, SO i am getting out of memory error.

I have below questions as part of the current scenario;

  1. What kind of query should i use for large set of queries. Currently I
    am using boolenquery and also springESTemplate.
  2. How to release memory after executing query

Please help me out. Thanks.

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
For more options, visit