# How to create a numeric not equals filter/query?

**URL:** <https://discuss.elastic.co/t/how-to-create-a-numeric-not-equals-filter-query/9429>\
**Category:** Elasticsearch\
**Created:** [October 20, 2012, 4:29pm UTC](https://discuss.elastic.co/t/how-to-create-a-numeric-not-equals-filter-query/9429 "2012-10-20T16:29:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![T\_Vinod\_Gupta](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@T\_Vinod\_Gupta](https://discuss.elastic.co/u/T_Vinod_Gupta)\
**Post date:** [October 20, 2012, 4:29pm UTC](https://discuss.elastic.co/t/how-to-create-a-numeric-not-equals-filter-query/9429/1 "2012-10-20T16:29:05Z")

</div>

in the documentation, i see numeric range filters.. but i want to check for  
a double field not equal to given value. currently im using not filter with  
term filter.. it works but is that the most efficient way?

thanks

--

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [October 20, 2012, 5:04pm UTC](https://discuss.elastic.co/t/how-to-create-a-numeric-not-equals-filter-query/9429/2 "2012-10-20T17:04:04Z")

</div>

On Sat, 2012-10-20 at 09:29 -0700, T Vinod Gupta wrote:

> in the documentation, i see numeric range filters.. but i want to  
> check for a double field not equal to given value. currently im using  
> not filter with term filter.. it works but is that the most efficient  
> way?

That's the correct way.

Also note: you can use the range filter for numbers as well. The  
numeric\_range filter is intended for fields (numbers, dates, terms) that  
have many many unique values. It works by building a field cache (ie  
loading all values for the field into memory). It may be the right  
filter to use for (eg) timestamp \> yesterday. But if your use case is  
(eg) age \> 18, then you'd be better off using a range filter.

clint

--

---

<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, 3:07am UTC](https://discuss.elastic.co/t/how-to-create-a-numeric-not-equals-filter-query/9429/3 "2017-07-06T03:07:50Z")

</div>


