# Search in array of object not display results

**URL:** <https://discuss.elastic.co/t/search-in-array-of-object-not-display-results/84265>\
**Category:** Elasticsearch\
**Created:** [May 2, 2017, 1:09pm UTC](https://discuss.elastic.co/t/search-in-array-of-object-not-display-results/84265 "2017-05-02T13:09:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xnukes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xnukes/32/17750_2.png) [@xnukes](https://discuss.elastic.co/u/xnukes)\
**Post date:** [May 2, 2017, 1:09pm UTC](https://discuss.elastic.co/t/search-in-array-of-object-not-display-results/84265/1 "2017-05-02T13:09:10Z")

</div>

Hello, please i have an map Project:  
{  
"id": {  
"type": "integer",  
"index": "not\_analyzed"  
},  
"accountId": {  
"type": "integer",  
"index": "not\_analyzed"  
},  
"clientId": {  
"type": "integer",  
"index": "not\_analyzed"  
},  
"ownerId": {  
"type": "integer",  
"index": "not\_analyzed"  
},  
"implementerId": {  
"type": "integer",  
"index": "not\_analyzed"  
},  
"name": {  
"type": "string",  
"index": "analyzed",  
"analyzer": "hunspell\_cs"  
},  
"description": {  
"type": "string",  
"index": "analyzed",  
"analyzer": "hunspell\_cs"  
},  
"visible": {  
"type": "integer",  
"index": "not\_analyzed"  
},  
"created": {  
"type": "date",  
"index": "not\_analyzed"  
},  
"deadline": {  
"type": "date",  
"index": "not\_analyzed"  
},  
"users": {  
"type": "nested",  
"properties": {  
"id": { "type": "integer" },  
"name": { "type": "string" }  
}  
}  
}

and document is filled as this:  
{  
"\_index": "es-main",  
"\_type": "Project",  
"\_id": "24",  
"\_score": 1,  
"\_source": {  
"id": 24,  
"accountId": 1,  
"clientId": null,  
"ownerId": 2,  
"implementerId": 7,  
"name": "IL - Integrated life",  
"description": null,  
"visible": 1,  
"created": "2016-11-24",  
"deadline": "2016-11-24",  
"users": [  
{  
"id": 2,  
"name": "Jakub Helešic"  
},  
{  
"id": 7,  
"name": "Josef Andrle"  
},  
{  
"id": 10,  
"name": "Michaela Niečová"  
},  
{  
"id": 9,  
"name": "Roman Kratochvíl"  
}  
],  
"\_is\_Project": 1  
}  
}

how to search by [users.id](http://users.id) = 2 ?

my query does not display anything. query is :  
GET /es-main/Project/\_search  
{  
"query" : {  
"bool": {  
"must": [  
{ "match": { "[users.id](http://users.id)": 2} }  
]  
}  
}  
}

Thanks all for reply

---

<div class="post-metadata">

**Author:** ![Nilabhsagar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nilabhsagar/32/10647_2.png) [@Nilabhsagar](https://discuss.elastic.co/u/Nilabhsagar)\
**Post date:** [May 2, 2017, 1:29pm UTC](https://discuss.elastic.co/t/search-in-array-of-object-not-display-results/84265/2 "2017-05-02T13:29:05Z")

</div>

You will have to use nested query as below  
POST /es-main/Project/\_search

```
{
  "query": {
    "nested": {
      "path": "users",
      "query": {
        "bool": {
          "must": {
            "match": {
              "users.id": 2
            }
          }
        }
      }
    }
  }
}

```

You can read more about nested query [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html)

You ca also use [inner\_hits](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-inner-hits.html) to extract the matching inner nested docs.

---

<div class="post-metadata">

**Author:** ![xnukes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xnukes/32/17750_2.png) [@xnukes](https://discuss.elastic.co/u/xnukes)\
**Post date:** [May 2, 2017, 1:33pm UTC](https://discuss.elastic.co/t/search-in-array-of-object-not-display-results/84265/3 "2017-05-02T13:33:16Z")

</div>

yes, thanks you very much !!!

---

<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:** [May 30, 2017, 1:38pm UTC](https://discuss.elastic.co/t/search-in-array-of-object-not-display-results/84265/4 "2017-05-30T13:38:53Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
