# Documents that only contain integers

**URL:** <https://discuss.elastic.co/t/documents-that-only-contain-integers/5180>\
**Category:** Elasticsearch\
**Created:** [August 17, 2011, 8:38am UTC](https://discuss.elastic.co/t/documents-that-only-contain-integers/5180 "2011-08-17T08:38:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rcch](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@rcch](https://discuss.elastic.co/u/rcch)\
**Post date:** [August 17, 2011, 8:38am UTC](https://discuss.elastic.co/t/documents-that-only-contain-integers/5180/1 "2011-08-17T08:38:31Z")

</div>

Hi all,

I have a search problem where my documents only contain integers (typically  
a few thousand per doc)..and I need to do an exact search for an input set  
of integers.

I was thinking of just adding them as normal files (strings- space  
delimted), and then searching them.

Is there a more efficient way of searching, given the peculiar nature of the  
problem? Maybe, using one or the more complex types that elastic search  
supports ?

Thanks for your input.

Cheers,

Vijay

---

<div class="post-metadata">

**Author:** ![rcch](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@rcch](https://discuss.elastic.co/u/rcch)\
**Post date:** [August 18, 2011, 7:47am UTC](https://discuss.elastic.co/t/documents-that-only-contain-integers/5180/2 "2011-08-18T07:47:17Z")

</div>

Can I get some suggestions on this ?

Thanks,

Vijay

On Aug 17, 1:38 am, Vijay Chandrasekhar [vijay....@gmail.com](mailto:vijay....@gmail.com) wrote:

> Hi all,
> 
> I have a search problem where my documents only contain integers (typically  
> a few thousand per doc)..and I need to do an exact search for an input set  
> of integers.
> 
> I was thinking of just adding them as normal files (strings- space  
> delimted), and then searching them.
> 
> Is there a more efficient way of searching, given the peculiar nature of the  
> problem? Maybe, using one or the more complex types that Elasticsearch  
> supports ?
> 
> Thanks for your input.
> 
> Cheers,
> 
> Vijay

---

<div class="post-metadata">

**Author:** ![Jan\_Fiedler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jan_fiedler/32/2518_2.png) [@Jan\_Fiedler](https://discuss.elastic.co/u/Jan_Fiedler)\
**Post date:** [August 18, 2011, 11:49am UTC](https://discuss.elastic.co/t/documents-that-only-contain-integers/5180/3 "2011-08-18T11:49:14Z")

</div>

I think indexing you documents with a single field carrying an array of  
integers (at the json level) should be appropriate. At query time you would  
then use a 'terms query' (  
[http://www.elasticsearch.org/guide/reference/query-dsl/terms-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/terms-query.html)) to  
match one (or more) integers against the field.

---

<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:56am UTC](https://discuss.elastic.co/t/documents-that-only-contain-integers/5180/4 "2017-07-06T03:56:43Z")

</div>


