# Question regarding TermsFacet

**URL:** <https://discuss.elastic.co/t/question-regarding-termsfacet/3859>\
**Category:** Elasticsearch\
**Created:** [February 1, 2011, 9:29pm UTC](https://discuss.elastic.co/t/question-regarding-termsfacet/3859 "2011-02-01T21:29:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Barak\_Yaish](https://avatars.discourse-cdn.com/v4/letter/b/9de053/32.png) [@Barak\_Yaish](https://discuss.elastic.co/u/Barak_Yaish)\
**Post date:** [February 1, 2011, 9:29pm UTC](https://discuss.elastic.co/t/question-regarding-termsfacet/3859/1 "2011-02-01T21:29:39Z")

</div>

Hello,

I'm trying to run facets against big index (45M docs) and have some  
questions:

1. Since the number of terms is unknown, I tried passing  
Integer.MAX\_VALUE as a size  
( addFacet( FacetBuilders.termsFacet( "facet1" ).field( "runId" ).size( size ).global( true ) )

- this caused exception in server, is this expected?

org.elasticsearch.transport.RemoteTransportException: [Catiana][inet[/  
10.80.0.23:9300]][search/phase/query]  
Caused by: java.util.NoSuchElementException  
at java.util.TreeMap.lastKey(TreeMap.java:1936)  
at java.util.TreeSet.last(TreeSet.java:384)  
at  
org.elasticsearch.common.collect.BoundedTreeSet.rebound(BoundedTreeSet.java:  
58)  
at  
org.elasticsearch.common.collect.BoundedTreeSet.add(BoundedTreeSet.java:  
46)  
at  
org.elasticsearch.search.facet.terms.strings.TermsStringFacetCollector.facet(TermsStringFacetCollector.java:  
137)  
at  
org.elasticsearch.search.facet.FacetPhase.execute(FacetPhase.java:88)  
at  
org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:192)  
at  
org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:  
173)  
at org.elasticsearch.search.action.SearchServiceTransportAction  
$SearchQueryTransportHandler.messageReceived(SearchServiceTransportAction.java:  
376)  
at org.elasticsearch.search.action.SearchServiceTransportAction  
$SearchQueryTransportHandler.messageReceived(SearchServiceTransportAction.java:  
367)  
at org.elasticsearch.transport.netty.MessageChannelHandler  
$3.run(MessageChannelHandler.java:195)  
at java.util.concurrent.ThreadPoolExecutor  
$Worker.runTask(ThreadPoolExecutor.java:886)  
at java.util.concurrent.ThreadPoolExecutor  
$Worker.run(ThreadPoolExecutor.java:908)  
at java.lang.Thread.run(Thread.java:619)

1. Following the above, how one should do facets queries against big  
index, I used to paginate queries with setFrom(), but it's not  
available for facets.

3.Is the data known ahead to ES (during the index build) or it re-  
calculated every call?

Thanks!

---

<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:** [July 6, 2017, 4:12am UTC](https://discuss.elastic.co/t/question-regarding-termsfacet/3859/2 "2017-07-06T04:12:56Z")

</div>


