# Search performance on elasticsearch

**URL:** <https://discuss.elastic.co/t/search-performance-on-elasticsearch/105400>\
**Category:** Elasticsearch\
**Created:** [October 26, 2017, 10:14am UTC](https://discuss.elastic.co/t/search-performance-on-elasticsearch/105400 "2017-10-26T10:14:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LakshmiTF](https://avatars.discourse-cdn.com/v4/letter/l/f475e1/32.png) [@LakshmiTF](https://discuss.elastic.co/u/LakshmiTF)\
**Post date:** [October 26, 2017, 10:14am UTC](https://discuss.elastic.co/t/search-performance-on-elasticsearch/105400/1 "2017-10-26T10:14:22Z")

</div>

Hi Team,

I have a requirement where in a search query results around 10 lacks of documents of elasticsearch.  
This search query is based on the aggreation.  
To get count of each bucket, I have iterated the buckets in the aggregation, get count of each bucket.

However since there are lacks of records and many buckets, iterating over the aggregating data is taking lot of time, giving performance issue.

is there any way that I can get record count [w.r.to](http://w.r.to) bucket with out iterating the aggregation.

And also is there any limit on the result of search query to get better performance.

Below is my code:

SearchResponse response =client.prepareSearch(Constants.GENSUITE\_PART\_FACET\_INDEX).setTypes(Constants.ITEM\_FACET\_MAP\_TYPE)  
.setQuery(QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("facetId", facetId))  
.must(QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("partTypeId", partTypeId))))  
_//_\*  
\* Increased Aggregation size.  
\* NREV-1220  
_//_  
.addAggregation(AggregationBuilders.terms("group\_by\_facet").field("facetData.keyword").order(Terms.Order.term(true)).size(Integer.MAX\_VALUE)).execute().actionGet();

for(Bucket entry : agg.getBuckets()){  
String facetData = entry.getKeyAsString()+"("+entry.getDocCount()+")";  
}

Please help me how can I resolve the performance issue.

Thanks,  
Lakshmi.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 23, 2017, 10:14am UTC](https://discuss.elastic.co/t/search-performance-on-elasticsearch/105400/2 "2017-11-23T10:14:50Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
