# Range Type - null values

**URL:** <https://discuss.elastic.co/t/range-type-null-values/106217>\
**Category:** Elasticsearch\
**Created:** [November 2, 2017, 4:22pm UTC](https://discuss.elastic.co/t/range-type-null-values/106217 "2017-11-02T16:22:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![morphers82](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/morphers82/32/22904_2.png) [@morphers82](https://discuss.elastic.co/u/morphers82)\
**Post date:** [November 2, 2017, 4:22pm UTC](https://discuss.elastic.co/t/range-type-null-values/106217/1 "2017-11-02T16:22:22Z")

</div>

How is a null value handled in a given range type , ie if doc has field with gte=null and lte=5 and a query looks for the value 4 in the range, will it bring up the doc with the given ranges or not?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [November 3, 2017, 2:54pm UTC](https://discuss.elastic.co/t/range-type-null-values/106217/2 "2017-11-03T14:54:00Z")

</div>

if you indexed a document where a field is either missing or set to `null`, then it is not part of your range. Only document that have this field set, will be part of the range.

You could use the [null\_value](https://www.elastic.co/guide/en/elasticsearch/reference/5.6/null-value.html) feature in the mapping to change this behaviour.

--Alex

---

<div class="post-metadata">

**Author:** ![morphers82](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/morphers82/32/22904_2.png) [@morphers82](https://discuss.elastic.co/u/morphers82)\
**Post date:** [November 13, 2017, 4:18pm UTC](https://discuss.elastic.co/t/range-type-null-values/106217/3 "2017-11-13T16:18:28Z")

</div>

that doesn't answer how a range type is handled when one of the values is null, ie gte=null & lte=500 and do a search on field for 400 inside the range, what happens?

---

<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:** [December 11, 2017, 4:18pm UTC](https://discuss.elastic.co/t/range-type-null-values/106217/4 "2017-12-11T16:18:38Z")

</div>

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