# Querying array of strings (multiword) with AND operator

**URL:** https://discuss.elastic.co/t/querying-array-of-strings-multiword-with-and-operator/21248
**Category:** Elasticsearch
**Created:** [December 14, 2014, 11:57am UTC](https://discuss.elastic.co/t/querying-array-of-strings-multiword-with-and-operator/21248 "2014-12-14T11:57:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Mathew\_Bolek](https://avatars.discourse-cdn.com/v4/letter/m/76d3ee/32.png) [@Mathew\_Bolek](https://discuss.elastic.co/u/Mathew_Bolek)
#### Post date: [December 14, 2014, 11:57am UTC](https://discuss.elastic.co/t/querying-array-of-strings-multiword-with-and-operator/21248/1 "2014-12-14T11:57:41Z")

</div>

Hi,

I really don't know what's wrong, but I seem to be unable to find a way of  
querying array elements that contain multiple words with "AND" operator.

ES version: 1.3.\*,  
only the default standard analyser in use

A dummy document

POST /dummy/location  
{  
"locationArray" : ["United Kindgom", "London"],  
"location" : "United Kingdom"  
}

It's mapping

GET /dummy/\_mapping  
{  
"dummy": {  
"mappings": {  
"location": {  
"properties": {  
"locationArray": {  
"type": "string"  
},  
"location": {  
"type": "string"  
}  
}  
}  
}  
}  
}

Query that matches "location" field OK:

GET /dummy/\_search  
{  
"query": {  
"match": {  
"location" : {  
"query" : "United Kingdom",  
"operator" : "AND"  
}  
}  
}  
}

_Problematic query that returns no results trying to match "locationArray"  
field:_

GET /dummy/\_search  
{  
"query": {  
"match": {  
"locationArray" : {  
"query" : "United Kingdom",  
"operator" : "AND"  
}  
}  
}  
}

I'd really appreciate a hint - there must be something obvious i'm missing  
/ not know about when querying that array field.

Cheers

--  
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/4179ca35-e376-471a-9228-1bf69b0bf550%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4179ca35-e376-471a-9228-1bf69b0bf550%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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: [December 14, 2014, 5:47pm UTC](https://discuss.elastic.co/t/querying-array-of-strings-multiword-with-and-operator/21248/2 "2014-12-14T17:47:12Z")

</div>

You have a typo:

POST /dummy/location  
{  
"locationArray" : ["United Kindgom", "London"],  
"location" : "United Kingdom"  
}

and I'm sure you mean

POST /dummy/location  
{  
"locationArray" : ["United Kingdom", "London"],  
"location" : "United Kingdom"  
}

Jörg

On Sun, Dec 14, 2014 at 12:57 PM, Mathew Bolek [borska.petra@gmail.com](mailto:borska.petra@gmail.com)  
wrote:

> Hi,
> 
> I really don't know what's wrong, but I seem to be unable to find a way of  
> querying array elements that contain multiple words with "AND" operator.
> 
> ES version: 1.3.\*,  
> only the default standard analyser in use
> 
> A dummy document
> 
> POST /dummy/location  
> {  
> "locationArray" : ["United Kindgom", "London"],  
> "location" : "United Kingdom"  
> }
> 
> It's mapping
> 
> GET /dummy/\_mapping  
> {  
> "dummy": {  
> "mappings": {  
> "location": {  
> "properties": {  
> "locationArray": {  
> "type": "string"  
> },  
> "location": {  
> "type": "string"  
> }  
> }  
> }  
> }  
> }  
> }
> 
> Query that matches "location" field OK:
> 
> GET /dummy/\_search  
> {  
> "query": {  
> "match": {  
> "location" : {  
> "query" : "United Kingdom",  
> "operator" : "AND"  
> }  
> }  
> }  
> }
> 
> _Problematic query that returns no results trying to match "locationArray"  
> field:_
> 
> GET /dummy/\_search  
> {  
> "query": {  
> "match": {  
> "locationArray" : {  
> "query" : "United Kingdom",  
> "operator" : "AND"  
> }  
> }  
> }  
> }
> 
> I'd really appreciate a hint - there must be something obvious i'm missing  
> / not know about when querying that array field.
> 
> Cheers
> 
> --  
> 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/4179ca35-e376-471a-9228-1bf69b0bf550%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4179ca35-e376-471a-9228-1bf69b0bf550%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/4179ca35-e376-471a-9228-1bf69b0bf550%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/4179ca35-e376-471a-9228-1bf69b0bf550%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAKdsXoFAPG66R6CbKz4q7Y4yNb3svEN\_DThXv88GkAj16yMnSA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoFAPG66R6CbKz4q7Y4yNb3svEN_DThXv88GkAj16yMnSA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:43am UTC](https://discuss.elastic.co/t/querying-array-of-strings-multiword-with-and-operator/21248/3 "2017-07-06T00:43:47Z")

</div>


