# Query a document by field which is an array of strings?

**URL:** <https://discuss.elastic.co/t/query-a-document-by-field-which-is-an-array-of-strings/15287>\
**Category:** Elasticsearch\
**Created:** [January 17, 2014, 2:44am UTC](https://discuss.elastic.co/t/query-a-document-by-field-which-is-an-array-of-strings/15287 "2014-01-17T02:44:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karan\_Verma](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@Karan\_Verma](https://discuss.elastic.co/u/Karan_Verma)\
**Post date:** [January 17, 2014, 2:44am UTC](https://discuss.elastic.co/t/query-a-document-by-field-which-is-an-array-of-strings/15287/1 "2014-01-17T02:44:20Z")

</div>

Hi

My field relevancy\_tags is index as an array of strings. A document is  
indexed with relevancy\_tags = ["a", "b","c","d"]. I want to return the  
document if the query is "a". I've tried using the term and terms filter  
but they don't return any results.

Help ☹ ?

Mapping:

"relevancy\_tags" : {

```
      "type" : "string"

    },

```

--  
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/fbb77163-246d-46b4-ba4d-25e98acdd308%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fbb77163-246d-46b4-ba4d-25e98acdd308%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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 17, 2014, 6:10am UTC](https://discuss.elastic.co/t/query-a-document-by-field-which-is-an-array-of-strings/15287/2 "2014-01-17T06:10:00Z")

</div>

In 0.90, we use english stopwords by default.

"A" is a stopword.

I guess it´s your issue.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 17 janv. 2014 à 03:44, Karan Verma [karan@healthtap.com](mailto:karan@healthtap.com) a écrit :

> Hi
> 
> My field relevancy\_tags is index as an array of strings. A document is indexed with relevancy\_tags = ["a", "b","c","d"]. I want to return the document if the query is "a". I've tried using the term and terms filter but they don't return any results.
> 
> Help ☹ ?
> 
> Mapping:
> 
> "relevancy\_tags" : {
> 
> ```
> "type" : "string"
> 
> },
> 
> ```
> 
> --  
> 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/fbb77163-246d-46b4-ba4d-25e98acdd308%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fbb77163-246d-46b4-ba4d-25e98acdd308%40googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/0A41FF2C-E8D6-4893-B7C0-C40B55528978%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/0A41FF2C-E8D6-4893-B7C0-C40B55528978%40pilato.fr).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Karan\_Verma](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@Karan\_Verma](https://discuss.elastic.co/u/Karan_Verma)\
**Post date:** [January 17, 2014, 6:38pm UTC](https://discuss.elastic.co/t/query-a-document-by-field-which-is-an-array-of-strings/15287/3 "2014-01-17T18:38:42Z")

</div>

Hi David

It is not a stopword issue, I just used the alphabets to simplify my  
question on this forum. Do you think that the term/terms filter would match  
the document?

Here is the query I am making. A lot of documents have relevancy\_tags  
as Psychiatry but none of them match when I use the explain API.

{  
"fields": ,  
"explain": true,  
"query": {  
"custom\_filters\_score": {  
"query": {  
"bool": {  
"must": [  
{  
"term": {  
"show\_in\_work\_queue": {  
"term": true  
}  
}  
}  
]  
}  
},  
"filters": [  
{  
"filter": {  
"term": {  
"verified\_answers\_count": {  
"term": 0  
}  
}  
},  
"boost": 256  
},  
{  
"filter": {  
"term": {  
"waiting\_for\_second\_opinion": {  
"term": true  
}  
}  
},  
"boost": 128  
},  
{  
"filter": {  
"term": {  
"relevancy\_tags": {  
"term": "Psychiatry"  
}  
}  
},  
"boost": 256  
},  
{  
"filter": {  
"terms": {  
"relevancy\_tags": [  
"Psychiatry",  
"Holistic Medicine",  
"Undersea and Hyperbaric Medicine"  
]  
}  
},  
"boost": 16  
},  
{  
"filter": {  
"terms": {  
"relevancy\_tags": [  
"Child Psychiatry",  
"Geriatric Psychiatry",  
"ADHD and Autism",  
"Addiction Medicine",  
"Clinical Psychology"  
]  
}  
},  
"boost": 4  
},  
{  
"filter": {  
"terms": {  
"relevancy\_tags": [  
"Child Psychiatry",  
"Geriatric Psychiatry",  
"ADHD and Autism",  
"Addiction Medicine",  
"Clinical Psychology"  
]  
}  
},  
"boost": 2  
}  
],  
"score\_mode": "total"  
}  
},  
"size": 30,  
"from": 0  
}

On Thu, Jan 16, 2014 at 10:10 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> In 0.90, we use english stopwords by default.
> 
> "A" is a stopword.
> 
> I guess it´s your issue.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 17 janv. 2014 à 03:44, Karan Verma [karan@healthtap.com](mailto:karan@healthtap.com) a écrit :
> 
> Hi
> 
> My field relevancy\_tags is index as an array of strings. A document is  
> indexed with relevancy\_tags = ["a", "b","c","d"]. I want to return the  
> document if the query is "a". I've tried using the term and terms filter  
> but they don't return any results.
> 
> Help ☹ ?
> 
> Mapping:
> 
> "relevancy\_tags" : {
> 
> ```
> "type" : "string"
> 
> },
> 
> ```
> 
> --  
> 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/fbb77163-246d-46b4-ba4d-25e98acdd308%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fbb77163-246d-46b4-ba4d-25e98acdd308%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/Iw6rMaP7BW0/unsubscribe](https://groups.google.com/d/topic/elasticsearch/Iw6rMaP7BW0/unsubscribe).  
> To unsubscribe from this group and all its topics, 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/0A41FF2C-E8D6-4893-B7C0-C40B55528978%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/0A41FF2C-E8D6-4893-B7C0-C40B55528978%40pilato.fr)  
> .
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Best,  
Karan

Life saving Ninja & Software Engineer

Karan pronounced Ka ([http://tiny.cc/0lu61w](http://tiny.cc/0lu61w)) + Run

--  
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/CAGX3c4Fojmp4EK4sVVNe%2BDUvwh%2BE7KtASoF8gAca\_Qnm0GW6HQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGX3c4Fojmp4EK4sVVNe%2BDUvwh%2BE7KtASoF8gAca_Qnm0GW6HQ%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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 17, 2014, 6:45pm UTC](https://discuss.elastic.co/t/query-a-document-by-field-which-is-an-array-of-strings/15287/4 "2014-01-17T18:45:51Z")

</div>

Use match queries or lowercase your search.

But it would be easier to answer with a simple full curl recreation as a Gist.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 17 janv. 2014 à 19:38, Karan Verma [karan@healthtap.com](mailto:karan@healthtap.com) a écrit :

> Psychiatry

--  
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/317AE917-EAA4-4743-8BC9-B9621298CFCF%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/317AE917-EAA4-4743-8BC9-B9621298CFCF%40pilato.fr).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Karan\_Verma](https://avatars.discourse-cdn.com/v4/letter/k/858c86/32.png) [@Karan\_Verma](https://discuss.elastic.co/u/Karan_Verma)\
**Post date:** [January 17, 2014, 7:12pm UTC](https://discuss.elastic.co/t/query-a-document-by-field-which-is-an-array-of-strings/15287/5 "2014-01-17T19:12:05Z")

</div>

Thanks David, making it a lowercase gave me the desired result. I guess  
because it not analyzed was not set in the mapping it was being converted  
it to lowercase before matching.

On Fri, Jan 17, 2014 at 10:45 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> Use match queries or lowercase your search.
> 
> But it would be easier to answer with a simple full curl recreation as a  
> Gist.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 17 janv. 2014 à 19:38, Karan Verma [karan@healthtap.com](mailto:karan@healthtap.com) a écrit :
> 
> > Psychiatry
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/Iw6rMaP7BW0/unsubscribe](https://groups.google.com/d/topic/elasticsearch/Iw6rMaP7BW0/unsubscribe).  
> To unsubscribe from this group and all its topics, 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/317AE917-EAA4-4743-8BC9-B9621298CFCF%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/317AE917-EAA4-4743-8BC9-B9621298CFCF%40pilato.fr)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Best,  
Karan

Life saving Ninja & Software Engineer

Karan pronounced Ka ([http://tiny.cc/0lu61w](http://tiny.cc/0lu61w)) + Run

--  
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/CAGX3c4Fd6RBgdK3eTDx9EJ-gEHx9be4nOh%2Bs3fSVA262\_eLmcg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGX3c4Fd6RBgdK3eTDx9EJ-gEHx9be4nOh%2Bs3fSVA262_eLmcg%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:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 17, 2014, 8:27pm UTC](https://discuss.elastic.co/t/query-a-document-by-field-which-is-an-array-of-strings/15287/6 "2014-01-17T20:27:29Z")

</div>

Exactly termQuery is not analyzed so its compared as is to the inverted index.  
Match query is analyzed.

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr

Le 17 janvier 2014 at 20:12:10, Karan Verma ([karan@healthtap.com](mailto:karan@healthtap.com)) a écrit:

Thanks David, making it a lowercase gave me the desired result. I guess because it not analyzed was not set in the mapping it was being converted it to lowercase before matching.

On Fri, Jan 17, 2014 at 10:45 AM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:  
Use match queries or lowercase your search.

But it would be easier to answer with a simple full curl recreation as a Gist.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 17 janv. 2014 à 19:38, Karan Verma [karan@healthtap.com](mailto:karan@healthtap.com) a écrit :

> Psychiatry

--  
You received this message because you are subscribed to a topic in the Google Groups "elasticsearch" group.  
To unsubscribe from this topic, visit [https://groups.google.com/d/topic/elasticsearch/Iw6rMaP7BW0/unsubscribe](https://groups.google.com/d/topic/elasticsearch/Iw6rMaP7BW0/unsubscribe).  
To unsubscribe from this group and all its topics, 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/317AE917-EAA4-4743-8BC9-B9621298CFCF%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/317AE917-EAA4-4743-8BC9-B9621298CFCF%40pilato.fr).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Best,  
Karan

Life saving Ninja & Software Engineer

## Karan pronounced Ka ([http://tiny.cc/0lu61w](http://tiny.cc/0lu61w)) + Run

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/CAGX3c4Fd6RBgdK3eTDx9EJ-gEHx9be4nOh%2Bs3fSVA262\_eLmcg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGX3c4Fd6RBgdK3eTDx9EJ-gEHx9be4nOh%2Bs3fSVA262_eLmcg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/etPan.52d99231.1f48eaa1.dc5%40MacBook-Air-de-David.local](https://groups.google.com/d/msgid/elasticsearch/etPan.52d99231.1f48eaa1.dc5%40MacBook-Air-de-David.local).  
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/query-a-document-by-field-which-is-an-array-of-strings/15287/7 "2017-07-06T01:56:06Z")

</div>


