# Exact matches on arrays

**URL:** https://discuss.elastic.co/t/exact-matches-on-arrays/15228
**Category:** Elasticsearch
**Created:** [January 14, 2014, 2:38am UTC](https://discuss.elastic.co/t/exact-matches-on-arrays/15228 "2014-01-14T02:38:41Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Justin\_Case](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justin_case/32/1867_2.png) [@Justin\_Case](https://discuss.elastic.co/u/Justin_Case)
#### Post date: [January 14, 2014, 2:38am UTC](https://discuss.elastic.co/t/exact-matches-on-arrays/15228/1 "2014-01-14T02:38:41Z")

</div>

How can I query an array for exact matches? (mapping is not\_analyzed).

e.g. I got a document with the tag [foo] and another one with the tags  
[foo, bar]. Only the document with the [foo] tag should return. Right now  
I'm using a script filter to limit the array  
length: [https://gist.github.com/justincase/b2efde40e19676df29c7](https://gist.github.com/justincase/b2efde40e19676df29c7). There must  
be an easier (and less compute expensive) way though?

--  
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/c69fc6bc-aba8-42ec-8000-b1f79bea18c2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/c69fc6bc-aba8-42ec-8000-b1f79bea18c2%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: ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)
#### Post date: [January 14, 2014, 10:08am UTC](https://discuss.elastic.co/t/exact-matches-on-arrays/15228/2 "2014-01-14T10:08:58Z")

</div>

Concatenate the array to a string, index it, and use simple string prefix  
matching.

Jörg

--  
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/CAKdsXoEOoamm3L0ChsyKxF%2B8wcq--hgWG9K3o02eKTP%3D72FwsA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEOoamm3L0ChsyKxF%2B8wcq--hgWG9K3o02eKTP%3D72FwsA%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: ![Justin\_Case](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/justin_case/32/1867_2.png) [@Justin\_Case](https://discuss.elastic.co/u/Justin_Case)
#### Post date: [January 14, 2014, 4:17pm UTC](https://discuss.elastic.co/t/exact-matches-on-arrays/15228/3 "2014-01-14T16:17:01Z")

</div>

Thanks Jörg,

I was hoping for an easier solution but it will do for now.  
Cheers.

On Jan 14, 2014, at 11:08 AM, [joergprante@gmail.com](mailto:joergprante@gmail.com) wrote:

> Concatenate the array to a string, index it, and use simple string prefix matching.
> 
> Jörg

--  
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/68FFBB8A-CE1D-47B4-934F-EEB0925EC1DD%40justincase.cx](https://groups.google.com/d/msgid/elasticsearch/68FFBB8A-CE1D-47B4-934F-EEB0925EC1DD%40justincase.cx).  
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:56am UTC](https://discuss.elastic.co/t/exact-matches-on-arrays/15228/4 "2017-07-06T01:56:54Z")

</div>


