# Exact match on an array field

**URL:** https://discuss.elastic.co/t/exact-match-on-an-array-field/6149
**Category:** Elasticsearch
**Created:** [December 13, 2011, 8:52pm UTC](https://discuss.elastic.co/t/exact-match-on-an-array-field/6149 "2011-12-13T20:52:36Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![marrese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marrese/32/3037_2.png) [@marrese](https://discuss.elastic.co/u/marrese)
#### Post date: [December 13, 2011, 8:52pm UTC](https://discuss.elastic.co/t/exact-match-on-an-array-field/6149/1 "2011-12-13T20:52:36Z")

</div>

Guys,

Hi, I have a document with many fields, and one of them is an array (a  
topics array). Currently that array has only one entry per document but in  
the future we'll have more entries. The thing is that I can't make an exact  
query on the topic array field when looking for more than one term in it.

Let say the documents stored have one of the following values on that  
field: _Martin_, _Martin Ariel_, _Ariel_, _Kyheo_  
So a doc will look something like this:

{  
'text': 'some random text',  
'date': '2011-12-12T15:17:35.000Z'.  
'topics': ['Martin']  
}

I'm doing this query (1) and the problem is that all the docs with _Kyheo_or  
_Martin_ or _Martin Ariel_ in the topic field are returned, but I only want  
those having _Kyheo_ or _Martin_. I'm stuck, looked in the docs but got  
confused. Any help please ?

Thanks,  
Martin

Links:  
1- [https://gist.github.com/1473724](https://gist.github.com/1473724)

--  
Martín

[http://www.kyheo.com.ar](http://www.kyheo.com.ar)  
GTalk: [marrese@gmail.com](mailto:marrese@gmail.com)

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [December 13, 2011, 11:03pm UTC](https://discuss.elastic.co/t/exact-match-on-an-array-field/6149/2 "2011-12-13T23:03:38Z")

</div>

Make the field as not\_analyzed, then it will be exact match. Though, in  
your case, you are testing for lowercase value, so if you want to ignore  
casing, you will need to create a custom analyzed with a keyword tokenized  
and a lowercase filter, and then associate it with the topics field in your  
mapping.

On Tue, Dec 13, 2011 at 10:52 PM, [marrese@gmail.com](mailto:marrese@gmail.com) [marrese@gmail.com](mailto:marrese@gmail.com)wrote:

> Guys,
> 
> Hi, I have a document with many fields, and one of them is an array (a  
> topics array). Currently that array has only one entry per document but in  
> the future we'll have more entries. The thing is that I can't make an exact  
> query on the topic array field when looking for more than one term in it.
> 
> Let say the documents stored have one of the following values on that  
> field: _Martin_, _Martin Ariel_, _Ariel_, _Kyheo_  
> So a doc will look something like this:
> 
> {  
> 'text': 'some random text',  
> 'date': '2011-12-12T15:17:35.000Z'.  
> 'topics': ['Martin']  
> }
> 
> I'm doing this query (1) and the problem is that all the docs with _Kyheo_or  
> _Martin_ or _Martin Ariel_ in the topic field are returned, but I only  
> want those having _Kyheo_ or _Martin_. I'm stuck, looked in the docs but  
> got confused. Any help please ?
> 
> Thanks,  
> Martin
> 
> Links:  
> 1- [https://gist.github.com/1473724](https://gist.github.com/1473724)
> 
> --  
> Martín
> 
> [http://www.kyheo.com.ar](http://www.kyheo.com.ar)  
> GTalk: [marrese@gmail.com](mailto:marrese@gmail.com)

---

<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:45am UTC](https://discuss.elastic.co/t/exact-match-on-an-array-field/6149/3 "2017-07-06T03:45:27Z")

</div>


