# Comparison operator

**URL:** <https://discuss.elastic.co/t/comparison-operator/3308>\
**Category:** Elasticsearch\
**Created:** [September 7, 2010, 6:01pm UTC](https://discuss.elastic.co/t/comparison-operator/3308 "2010-09-07T18:01:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei/32/2856_2.png) [@Andrei](https://discuss.elastic.co/u/Andrei)\
**Post date:** [September 7, 2010, 6:01pm UTC](https://discuss.elastic.co/t/comparison-operator/3308/1 "2010-09-07T18:01:03Z")

</div>

I have a "not analyzed" field that contains an integer. Can I use the  
query language to compare that integer to something, like 'field' \> 0,  
'field' \< 0, etc?

-Andrei

---

<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:** [September 7, 2010, 6:42pm UTC](https://discuss.elastic.co/t/comparison-operator/3308/2 "2010-09-07T18:42:46Z")

</div>

On Tue, 2010-09-07 at 11:01 -0700, Andrei wrote:

> I have a "not analyzed" field that contains an integer. Can I use the  
> query language to compare that integer to something, like 'field' \> 0,  
> 'field' \< 0, etc?

You can do less-than and greater-than with range filters and queries

And you can combine various ranges together with bool/and/or/not filters  
or with bool queries:

[http://www.elasticsearch.com/docs/elasticsearch/rest\_api/query\_dsl/](http://www.elasticsearch.com/docs/elasticsearch/rest_api/query_dsl/)

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, 4:19am UTC](https://discuss.elastic.co/t/comparison-operator/3308/3 "2017-07-06T04:19:39Z")

</div>


