# How do element-based array query?

**URL:** <https://discuss.elastic.co/t/how-do-element-based-array-query/23306>\
**Category:** Elasticsearch\
**Created:** [April 18, 2015, 2:33pm UTC](https://discuss.elastic.co/t/how-do-element-based-array-query/23306 "2015-04-18T14:33:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![terrasacer](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@terrasacer](https://discuss.elastic.co/u/terrasacer)\
**Post date:** [April 18, 2015, 2:33pm UTC](https://discuss.elastic.co/t/how-do-element-based-array-query/23306/1 "2015-04-18T14:33:48Z")

</div>

Hi guys,

My problem succinctly

POST tweet/test  
{  
"name": "Stefan",  
"address": ["Chine street",  
"England country"]  
}

POST tweet/test  
{  
"name": "Heroku",  
"address": ["bla bla street",  
"China country"]  
}

GET tweet/\_search  
{  
"query": {  
"query\_string": {  
"default\_field": "address",  
"query": "China country",  
"default\_operator": "AND"  
}

```
}

```

}

Response

{  
"took": 1,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 2,  
"max\_score": 0.15342641,  
"hits": [  
{  
"\_index": "tweet",  
"\_type": "test",  
"\_id": "AUzM7tcIO39NAgkFq0jl",  
"\_score": 0.15342641,  
"\_source": {  
"name": "Heroku",  
"address": [  
"China street",  
"Englang country"  
]  
}  
},  
{  
"\_index": "tweet",  
"\_type": "test",  
"\_id": "AUzM7w2kO39NAgkFq0jm",  
"\_score": 0.13424811,  
"\_source": {  
"name": "Heroku",  
"address": [  
"bla bla street",  
"China country"  
]  
}  
}  
]  
}  
}

Nasıl haritayı değiştirmeden yalnızca ikinci belge dönmek için alabilirim?

Best.

--  
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/647e9c10-f42c-42be-b15c-4603cb8d4c22%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/647e9c10-f42c-42be-b15c-4603cb8d4c22%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [April 18, 2015, 3:35pm UTC](https://discuss.elastic.co/t/how-do-element-based-array-query/23306/2 "2015-04-18T15:35:47Z")

</div>

You need to define nested documents.

--  
David Pilato - Developer | Evangelist

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co/)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

@dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr) | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)

> Le 18 avr. 2015 à 16:33, Terra Sacer [terrasacer@gmail.com](mailto:terrasacer@gmail.com) a écrit :
> 
> Hi guys,
> 
> My problem succinctly
> 
> POST tweet/test  
> {  
> "name": "Stefan",  
> "address": ["Chine street",  
> "England country"]  
> }
> 
> POST tweet/test  
> {  
> "name": "Heroku",  
> "address": ["bla bla street",  
> "China country"]  
> }
> 
> GET tweet/\_search  
> {  
> "query": {  
> "query\_string": {  
> "default\_field": "address",  
> "query": "China country",  
> "default\_operator": "AND"  
> }
> 
> ```
> }
> 
> ```
> 
> }
> 
> Response
> 
> {  
> "took": 1,  
> "timed\_out": false,  
> "\_shards": {  
> "total": 5,  
> "successful": 5,  
> "failed": 0  
> },  
> "hits": {  
> "total": 2,  
> "max\_score": 0.15342641,  
> "hits": [  
> {  
> "\_index": "tweet",  
> "\_type": "test",  
> "\_id": "AUzM7tcIO39NAgkFq0jl",  
> "\_score": 0.15342641,  
> "\_source": {  
> "name": "Heroku",  
> "address": [  
> "China street",  
> "Englang country"  
> ]  
> }  
> },  
> {  
> "\_index": "tweet",  
> "\_type": "test",  
> "\_id": "AUzM7w2kO39NAgkFq0jm",  
> "\_score": 0.13424811,  
> "\_source": {  
> "name": "Heroku",  
> "address": [  
> "bla bla street",  
> "China country"  
> ]  
> }  
> }  
> ]  
> }  
> }
> 
> Nasıl haritayı değiştirmeden yalnızca ikinci belge dönmek için alabilirim?
> 
> Best.
> 
> --  
> 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) [mailto:elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/647e9c10-f42c-42be-b15c-4603cb8d4c22%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/647e9c10-f42c-42be-b15c-4603cb8d4c22%40googlegroups.com) [https://groups.google.com/d/msgid/elasticsearch/647e9c10-f42c-42be-b15c-4603cb8d4c22%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/647e9c10-f42c-42be-b15c-4603cb8d4c22%40googlegroups.com?utm_medium=email&utm_source=footer).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout) [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/A5FC30FB-2869-4EF4-A79F-B5B6478C3C08%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/A5FC30FB-2869-4EF4-A79F-B5B6478C3C08%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![terrasacer](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@terrasacer](https://discuss.elastic.co/u/terrasacer)\
**Post date:** [April 18, 2015, 6:33pm UTC](https://discuss.elastic.co/t/how-do-element-based-array-query/23306/3 "2015-04-18T18:33:03Z")

</div>

Hello David,

I don't want to use the sub-area(address.street as).

Is it possible another solution?

On Saturday, April 18, 2015 at 6:36:09 PM UTC+3, David Pilato wrote:

> You need to define nested documents.
> 
> --  
> _David Pilato_ - Developer | Evangelist  
> _[elastic.co](http://elastic.co) [http://elastic.co](http://elastic.co)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr  
> [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr) | @scrutmydocs  
> [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> Le 18 avr. 2015 à 16:33, Terra Sacer \<[terra...@gmail.com](mailto:terra...@gmail.com) \<javascript:\>\> a  
> écrit :
> 
> Hi guys,
> 
> My problem succinctly
> 
> POST tweet/test  
> {  
> "name": "Stefan",  
> "address": ["Chine street",  
> "England country"]  
> }
> 
> POST tweet/test  
> {  
> "name": "Heroku",  
> "address": ["bla bla street",  
> "China country"]  
> }
> 
> GET tweet/\_search  
> {  
> "query": {  
> "query\_string": {  
> "default\_field": "address",  
> "query": "China country",  
> "default\_operator": "AND"  
> }
> 
> ```
> }
> 
> ```
> 
> }
> 
> Response
> 
> {  
> "took": 1,  
> "timed\_out": false,  
> "\_shards": {  
> "total": 5,  
> "successful": 5,  
> "failed": 0  
> },  
> "hits": {  
> "total": 2,  
> "max\_score": 0.15342641,  
> "hits": [  
> {  
> "\_index": "tweet",  
> "\_type": "test",  
> "\_id": "AUzM7tcIO39NAgkFq0jl",  
> "\_score": 0.15342641,  
> "\_source": {  
> "name": "Heroku",  
> "address": [  
> "China street",  
> "Englang country"  
> ]  
> }  
> },  
> {  
> "\_index": "tweet",  
> "\_type": "test",  
> "\_id": "AUzM7w2kO39NAgkFq0jm",  
> "\_score": 0.13424811,  
> "\_source": {  
> "name": "Heroku",  
> "address": [  
> "bla bla street",  
> "China country"  
> ]  
> }  
> }  
> ]  
> }  
> }
> 
> Nasıl haritayı değiştirmeden yalnızca ikinci belge dönmek için alabilirim?
> 
> Best.
> 
> --  
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/647e9c10-f42c-42be-b15c-4603cb8d4c22%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/647e9c10-f42c-42be-b15c-4603cb8d4c22%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/647e9c10-f42c-42be-b15c-4603cb8d4c22%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/647e9c10-f42c-42be-b15c-4603cb8d4c22%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/3f2139fa-14ad-4758-a7e8-bf3de8172115%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3f2139fa-14ad-4758-a7e8-bf3de8172115%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![terrasacer](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@terrasacer](https://discuss.elastic.co/u/terrasacer)\
**Post date:** [April 18, 2015, 10:38pm UTC](https://discuss.elastic.co/t/how-do-element-based-array-query/23306/4 "2015-04-18T22:38:11Z")

</div>

Hello David,

match\_phrase was a solution to the problem seems.

On Saturday, April 18, 2015 at 6:36:09 PM UTC+3, David Pilato wrote:

> You need to define nested documents.
> 
> --  
> _David Pilato_ - Developer | Evangelist  
> _[elastic.co](http://elastic.co) [http://elastic.co](http://elastic.co)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr  
> [https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr) | @scrutmydocs  
> [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> Le 18 avr. 2015 à 16:33, Terra Sacer \<[terra...@gmail.com](mailto:terra...@gmail.com) \<javascript:\>\> a  
> écrit :
> 
> Hi guys,
> 
> My problem succinctly
> 
> POST tweet/test  
> {  
> "name": "Stefan",  
> "address": ["Chine street",  
> "England country"]  
> }
> 
> POST tweet/test  
> {  
> "name": "Heroku",  
> "address": ["bla bla street",  
> "China country"]  
> }
> 
> GET tweet/\_search  
> {  
> "query": {  
> "query\_string": {  
> "default\_field": "address",  
> "query": "China country",  
> "default\_operator": "AND"  
> }
> 
> ```
> }
> 
> ```
> 
> }
> 
> Response
> 
> {  
> "took": 1,  
> "timed\_out": false,  
> "\_shards": {  
> "total": 5,  
> "successful": 5,  
> "failed": 0  
> },  
> "hits": {  
> "total": 2,  
> "max\_score": 0.15342641,  
> "hits": [  
> {  
> "\_index": "tweet",  
> "\_type": "test",  
> "\_id": "AUzM7tcIO39NAgkFq0jl",  
> "\_score": 0.15342641,  
> "\_source": {  
> "name": "Heroku",  
> "address": [  
> "China street",  
> "Englang country"  
> ]  
> }  
> },  
> {  
> "\_index": "tweet",  
> "\_type": "test",  
> "\_id": "AUzM7w2kO39NAgkFq0jm",  
> "\_score": 0.13424811,  
> "\_source": {  
> "name": "Heroku",  
> "address": [  
> "bla bla street",  
> "China country"  
> ]  
> }  
> }  
> ]  
> }  
> }
> 
> Nasıl haritayı değiştirmeden yalnızca ikinci belge dönmek için alabilirim?
> 
> Best.
> 
> --  
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/647e9c10-f42c-42be-b15c-4603cb8d4c22%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/647e9c10-f42c-42be-b15c-4603cb8d4c22%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/647e9c10-f42c-42be-b15c-4603cb8d4c22%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/647e9c10-f42c-42be-b15c-4603cb8d4c22%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/8f1e8f00-81e8-4d38-9c52-b88c4eb1eabc%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8f1e8f00-81e8-4d38-9c52-b88c4eb1eabc%40googlegroups.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:18am UTC](https://discuss.elastic.co/t/how-do-element-based-array-query/23306/5 "2017-07-06T00:18:53Z")

</div>


