# Term filter: integer vs string?

**URL:** <https://discuss.elastic.co/t/term-filter-integer-vs-string/15107>\
**Category:** Elasticsearch\
**Created:** [January 4, 2014, 2:34pm UTC](https://discuss.elastic.co/t/term-filter-integer-vs-string/15107 "2014-01-04T14:34:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![arthurx](https://avatars.discourse-cdn.com/v4/letter/a/ecd19e/32.png) [@arthurx](https://discuss.elastic.co/u/arthurx)\
**Post date:** [January 4, 2014, 2:34pm UTC](https://discuss.elastic.co/t/term-filter-integer-vs-string/15107/1 "2014-01-04T14:34:55Z")

</div>

I saw that in the term filter doc page  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html)  
it shows an example

curl -XPUT localhost:9200/tweets/tweet/1 -d '{  
"user" : "2"  
}'

here the user id "2" is put as string. In other databases generally one  
would use an integer field to represent such id. I wonder is there any  
difference in performance (mainly concerning term filter) between string vs  
integer?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5f1db06b-dcf9-44d2-ac04-8fe625f33ade%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5f1db06b-dcf9-44d2-ac04-8fe625f33ade%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [January 4, 2014, 3:56pm UTC](https://discuss.elastic.co/t/term-filter-integer-vs-string/15107/2 "2014-01-04T15:56:46Z")

</div>

The way the term filter is executed is the same for strings and integers so  
I wouldn't expect any performance difference here.

On Sat, Jan 4, 2014 at 3:34 PM, arthurX [fc28222@gmail.com](mailto:fc28222@gmail.com) wrote:

> I saw that in the term filter doc page
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-terms-filter.html)  
> it shows an example
> 
> curl -XPUT localhost:9200/tweets/tweet/1 -d '{  
> "user" : "2"  
> }'
> 
> here the user id "2" is put as string. In other databases generally one  
> would use an integer field to represent such id. I wonder is there any  
> difference in performance (mainly concerning term filter) between string vs  
> integer?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/5f1db06b-dcf9-44d2-ac04-8fe625f33ade%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5f1db06b-dcf9-44d2-ac04-8fe625f33ade%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Adrien Grand

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5SC\_ymGiLS253KWzAFT2TLGGAXiWNB8UUexeZuj0Xieg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j5SC_ymGiLS253KWzAFT2TLGGAXiWNB8UUexeZuj0Xieg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 1:58am UTC](https://discuss.elastic.co/t/term-filter-integer-vs-string/15107/3 "2017-07-06T01:58:21Z")

</div>


