# Ошибка please use TotalHitCountCollector if you just need the total hit count

**URL:** <https://discuss.elastic.co/t/please-use-totalhitcountcollector-if-you-just-need-the-total-hit-count/58984>\
**Category:** Вопросы на русском языке\
**Created:** [August 25, 2016, 9:30pm UTC](https://discuss.elastic.co/t/please-use-totalhitcountcollector-if-you-just-need-the-total-hit-count/58984 "2016-08-25T21:30:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maksym\_Seleznev](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@Maksym\_Seleznev](https://discuss.elastic.co/u/Maksym_Seleznev)\
**Post date:** [August 25, 2016, 9:30pm UTC](https://discuss.elastic.co/t/please-use-totalhitcountcollector-if-you-just-need-the-total-hit-count/58984/1 "2016-08-25T21:30:41Z")

</div>

часто падает такая ошибка но не знаю на какой запрос, можно как то отследить и что за сообщение в виде **" IllegalArgumentException[numHits must be \> 0; please use TotalHitCountCollector if you just need the total hit count"**?

что за TotalHitCountCollector? подсчет сколько записей нашел запрос делаю

```
[2016-08-25 04:07:32,416][DEBUG][action.search] [node-1] All shards failed for phase: [query]
RemoteTransportException[[node-1][10.0.2.253:9300][indices:data/read/search[phase/query]]]; nested: QueryPhaseExecutionException[Query Failed [Failed to execute main query]]; nested: IllegalArgumentException[numHits must be > 0; please use TotalHitCountCollector if you just need the total hit count];
Caused by: QueryPhaseExecutionException[Query Failed [Failed to execute main query]]; nested: IllegalArgumentException[numHits must be > 0; please use TotalHitCountCollector if you just need the total hit count];
	at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:415)
	at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:130)
	at org.elasticsearch.search.SearchService.loadOrExecuteQueryPhase(SearchService.java:273)
	at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:285)
	at org.elasticsearch.search.action.SearchTransportService$SearchQueryTransportHandler.messageReceived(SearchTransportService.java:315)
	at org.elasticsearch.search.action.SearchTransportService$SearchQueryTransportHandler.messageReceived(SearchTransportService.java:312)
	at org.elasticsearch.transport.TransportRequestHandler.messageReceived(TransportRequestHandler.java:33)
	at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:66)
	at org.elasticsearch.transport.TransportService$4.doRun(TransportService.java:382)
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:452)
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: numHits must be > 0; please use TotalHitCountCollector if you just need the total hit count
	at org.apache.lucene.search.TopFieldCollector.create(TopFieldCollector.java:489)
	at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:232)
	... 13 more
```

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [August 25, 2016, 9:34pm UTC](https://discuss.elastic.co/t/please-use-totalhitcountcollector-if-you-just-need-the-total-hit-count/58984/2 "2016-08-25T21:34:45Z")

</div>

> **[elastic/elasticsearch](https://github.com/elastic/elasticsearch/search?q=%22IllegalArgumentException%5BnumHits+must+be+%3E+0%3B+please+use+TotalHitCountCollector+if+you+just+need+the+total+hit+count%22&type=Issues&utf8=%E2%9C%93)**
>
> elasticsearch - Open Source, Distributed, RESTful Search Engine

---

<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, 1:46pm UTC](https://discuss.elastic.co/t/please-use-totalhitcountcollector-if-you-just-need-the-total-hit-count/58984/3 "2017-07-06T13:46:02Z")

</div>


