# Enforce minimum hit count on all queries by default

**URL:** <https://discuss.elastic.co/t/enforce-minimum-hit-count-on-all-queries-by-default/121754>\
**Category:** Elasticsearch\
**Created:** [February 28, 2018, 12:14am UTC](https://discuss.elastic.co/t/enforce-minimum-hit-count-on-all-queries-by-default/121754 "2018-02-28T00:14:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![s\_mp](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@s\_mp](https://discuss.elastic.co/u/s_mp)\
**Post date:** [February 28, 2018, 12:14am UTC](https://discuss.elastic.co/t/enforce-minimum-hit-count-on-all-queries-by-default/121754/1 "2018-02-28T00:14:40Z")

</div>

Hi,  
Our ES index consists of user records with "Personally identifiable information"(PII). And all the data is supposed to be queried only at the aggregated level.  
We currently ask all our clients to include min\_doc\_count in the terms aggregation. However, we are looking for a possibility of enforcing some threshold by default. So if the terms aggregation doesn't have a min\_doc\_count defined, we would want to enforce it with minimum hit count threshold.  
Is this possible via a index/cluster level config or as a filtered alias or something ?

thanks.  
Srini

---

<div class="post-metadata">

**Author:** ![s\_mp](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@s\_mp](https://discuss.elastic.co/u/s_mp)\
**Post date:** [February 28, 2018, 11:39pm UTC](https://discuss.elastic.co/t/enforce-minimum-hit-count-on-all-queries-by-default/121754/2 "2018-02-28T23:39:48Z")

</div>

Can someone respond to this plz ?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 1, 2018, 12:15am UTC](https://discuss.elastic.co/t/enforce-minimum-hit-count-on-all-queries-by-default/121754/3 "2018-03-01T00:15:25Z")

</div>

Read [this](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and specifically the "Also be patient" part.

At least wait for 2 or 3 days before asking again. Thanks.

---

<div class="post-metadata">

**Author:** ![s\_mp](https://avatars.discourse-cdn.com/v4/letter/s/f9ae1b/32.png) [@s\_mp](https://discuss.elastic.co/u/s_mp)\
**Post date:** [March 6, 2018, 10:49pm UTC](https://discuss.elastic.co/t/enforce-minimum-hit-count-on-all-queries-by-default/121754/4 "2018-03-06T22:49:45Z")

</div>

Hi,  
We are planning to write custom REST end points and extend RestResponseListener, where we parse the response and if the hits is less than our configured threshold, we send empty response to the client with a message.  
Something on the lines of [this CSV implementation.](https://github.com/jprante/elasticsearch-csv/blob/1ae3c9c7013b1dbd5350d4c14f7e2e340d59e0bb/src/main/java/org/xbib/elasticsearch/rest/csv/CSVToXContentListener.java)  
Downside is that we have to wait for the full request execution, before we make the call on hits threshold.  
Please let me know if any alternatives are possible.

thanks,  
Srini

---

<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:** [April 3, 2018, 10:50pm UTC](https://discuss.elastic.co/t/enforce-minimum-hit-count-on-all-queries-by-default/121754/5 "2018-04-03T22:50:17Z")

</div>

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