# Hits relation constant value - gte - greater than or equal to

**URL:** <https://discuss.elastic.co/t/hits-relation-constant-value-gte-greater-than-or-equal-to/218037>\
**Category:** Elasticsearch\
**Created:** [February 5, 2020, 5:38pm UTC](https://discuss.elastic.co/t/hits-relation-constant-value-gte-greater-than-or-equal-to/218037 "2020-02-05T17:38:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrey\_Masunov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrey_masunov/32/45836_2.png) [@Andrey\_Masunov](https://discuss.elastic.co/u/Andrey_Masunov)\
**Post date:** [February 5, 2020, 5:38pm UTC](https://discuss.elastic.co/t/hits-relation-constant-value-gte-greater-than-or-equal-to/218037/1 "2020-02-05T17:38:28Z")

</div>

From documentation:  
[https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-request-body.html#request-body-search-track-total-hits](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-request-body.html#request-body-search-track-total-hits)

"If the total number of hits that match the query is **greater than the value** set in `track_total_hits` , the total hits in the response will indicate that the returned value is a lower bound:"

```
{
    "_shards": ...
    "hits" : {
        "max_score": 1.0,
        "total" : {
            "value": 100,         
            "relation": "gte"     
        },
        "hits": ...
    }
}

```

"gte" - means "greater than or equal to", why you are using this expression, instead of "gt" - "greater than". **greater than the value** - means cannot be equal

Could you please clarify the logic of this abbreviation.  
Best regards, Andrey

---

<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:** [February 5, 2020, 7:49pm UTC](https://discuss.elastic.co/t/hits-relation-constant-value-gte-greater-than-or-equal-to/218037/2 "2020-02-05T19:49:07Z")

</div>

@jimczi Should we consider this as a bug?

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [February 6, 2020, 8:29am UTC](https://discuss.elastic.co/t/hits-relation-constant-value-gte-greater-than-or-equal-to/218037/3 "2020-02-06T08:29:00Z")

</div>

The documentation is misleading, I agree. It should say `"If the total number of hits that match the query is greater or equals than the value..`. Can you open an issue ?

---

<div class="post-metadata">

**Author:** ![Andrey\_Masunov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrey_masunov/32/45836_2.png) [@Andrey\_Masunov](https://discuss.elastic.co/u/Andrey_Masunov)\
**Post date:** [February 6, 2020, 9:22am UTC](https://discuss.elastic.co/t/hits-relation-constant-value-gte-greater-than-or-equal-to/218037/4 "2020-02-06T09:22:11Z")

</div>

@jimczi should value "greater than or equal to" also be changed to "greater than"?

(example for 10000 default value)

according to current implementation:

- "equal to" is for range from 1 to 10000
- "greater than or equal to" is for range from 10001  
But 10001 is already not equal, its just "greater than"

If you just change documentation, you expect that

- "equal to" is for range from 1 to 9999
- "greater than or equal to" is for range from 10000  
But current implementation is different

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [February 6, 2020, 10:00am UTC](https://discuss.elastic.co/t/hits-relation-constant-value-gte-greater-than-or-equal-to/218037/5 "2020-02-06T10:00:07Z")

</div>

we should never return a value that is greater than the provided `track_total_hits` so if you set `10000` you can only have values that range between 0 and 10000. The relation will be `eq` for results between 0 and 9999 and `10000` will set the relation to `gte` so I think we're good ?

---

<div class="post-metadata">

**Author:** ![Andrey\_Masunov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrey_masunov/32/45836_2.png) [@Andrey\_Masunov](https://discuss.elastic.co/u/Andrey_Masunov)\
**Post date:** [February 6, 2020, 11:26am UTC](https://discuss.elastic.co/t/hits-relation-constant-value-gte-greater-than-or-equal-to/218037/6 "2020-02-06T11:26:19Z")

</div>

But, I mean, that we cannot be sure in that case, if 10000 is equal or already not? E.g. if there are 10000 we got "equal".

"greater than or equal to" leads to the suspense. It can be greater OR equal  
At the same time, "greater than" - just greater than the current value.

Why it cannot be just "greater than" starting when the value is more than 10000  
If its 10000 and less, will be "equal"

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [February 6, 2020, 11:41am UTC](https://discuss.elastic.co/t/hits-relation-constant-value-gte-greater-than-or-equal-to/218037/7 "2020-02-06T11:41:47Z")

</div>

> Why it cannot be just "greater than" starting when the value is more than 10000  
> If its 10000 and less, will be "equal"

Because that's the limit where we stop counting, when we reach `10000` documents in your case. So we don't know if there are more documents or not, the only thing we know is that we collected `10000` documents so the value total number can be equals or greater than this value.

---

<div class="post-metadata">

**Author:** ![Andrey\_Masunov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrey_masunov/32/45836_2.png) [@Andrey\_Masunov](https://discuss.elastic.co/u/Andrey_Masunov)\
**Post date:** [February 6, 2020, 12:01pm UTC](https://discuss.elastic.co/t/hits-relation-constant-value-gte-greater-than-or-equal-to/218037/8 "2020-02-06T12:01:26Z")

</div>

> [@jimczi](#):
>
> and `10000` will set the relation to `gte` so I think we're good ?

we got "eq" instead of "gte"

---

<div class="post-metadata">

**Author:** ![jimczi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jimczi/32/47985_2.png) [@jimczi](https://discuss.elastic.co/u/jimczi)\
**Post date:** [February 6, 2020, 12:19pm UTC](https://discuss.elastic.co/t/hits-relation-constant-value-gte-greater-than-or-equal-to/218037/9 "2020-02-06T12:19:41Z")

</div>

Ah sorry I forgot that we have a special handling in Elasticsearch that differs from Lucene. We count accurately up to `10,000` and return `gte` for values that are greater so you're right. I also agree that it can be confusing so can you open an issue in Lucene. I am on vacations now but will take a look when I come back or someone else from the team will pick that up. Thanks for catching this @Andrey_Masunov!

---

<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:** [March 5, 2020, 12:19pm UTC](https://discuss.elastic.co/t/hits-relation-constant-value-gte-greater-than-or-equal-to/218037/10 "2020-03-05T12:19:50Z")

</div>

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