Filed to execute main query

I have faced a issue in searching,I am continuously getting out of memory in the particular index.

Caused by: java.lang.OutOfMemoryError: Java heap space
[2016-02-15 06:18:08,400][DEBUG][action.search.type ] [10.1.0.31] All shards failed for phase: [query_fetch]
org.elasticsearch.transport.RemoteTransportException: [10.1.0.31][inet[/10.1.0.37:9300]][indices:data/read/search[phase/query+fetch]]
Caused by: org.elasticsearch.search.query.QueryPhaseExecutionException: [unknown][0]: query[ConstantScore(+cache(first_occurance:[1455476225000 TO 1455476230999]))],from[0],size[10],sort[<custom:"first_occurance": org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource@4c0e352d>!]: Query Failed [Failed to execute main query]

In the above exception i am getting ,when i tried to execute the ascending order,But if there is no soting i am not getting the exception,Eventhough my search criteria is matched with only 10 records also it won't execute.

Thanks
Moni

What does the query look like?

Hi Mark ,

I found the problem in index mappings , I have missed the "fielddata": {"format": "doc_values"} in mappings for that particular column.So when i have aggregated the particular field it will load everything on memory instead of disk.So i am getting that exception continuously.

Thanks for you immediate attention.

Thanks
Moni