# Strange result of search children by parent

**URL:** <https://discuss.elastic.co/t/strange-result-of-search-children-by-parent/7774>\
**Category:** Elasticsearch\
**Created:** [May 19, 2012, 3:58pm UTC](https://discuss.elastic.co/t/strange-result-of-search-children-by-parent/7774 "2012-05-19T15:58:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxkazar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maxkazar/32/2880_2.png) [@maxkazar](https://discuss.elastic.co/u/maxkazar)\
**Post date:** [May 19, 2012, 3:58pm UTC](https://discuss.elastic.co/t/strange-result-of-search-children-by-parent/7774/1 "2012-05-19T15:58:09Z")

</div>

I need find all children by parent id. In my case i have notifications and each notification has documents.

I try to search all documents for some notifications like this

{  
"fields": [  
"highlight",  
"\_parent"  
],  
"query": {  
"bool": {  
"must": [  
{  
"terms": {  
"\_parent": [  
"4fadd2c31f48d548f5000001",  
"4faf79c61f48d548f1000006",  
"4fae27eb1f48d55f68000006",  
"4fadf6f61f48d54820000002",  
"4fae39911f48d57e3f000002",  
"4fae42681f48d52b6f000001",  
"4faf79c61f48d548f1000005",  
"4fadf0c41f48d534eb000024",  
"4fae11381f48d5586400000a",  
"4fae07611f48d55cae000014"  
],  
"minimum\_match": 1  
}  
}  
],  
"should": [  
{  
"query\_string": {  
"fields": [  
"content"  
],  
"query": "test"  
}  
}  
]  
}  
},  
"highlight": {  
"fields": {  
"content": {  
"fragment\_size": 100,  
"number\_of\_fragments": 1,  
"order": "score"  
}  
}  
}  
}

and every time result is different. One time result contain 3 items and second 5 items. ElasticSearch has to nodes with 10 shards (version 1.9.3)

I simplified search query:  
{  
"fields": [  
"name"  
],  
"query": {  
"term": {  
"\_parent": "4fae3e3d1f48d5261c000033"  
}  
}  
}

result the same, return one document or nothing

---

<div class="post-metadata">

**Author:** ![maxkazar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maxkazar/32/2880_2.png) [@maxkazar](https://discuss.elastic.co/u/maxkazar)\
**Post date:** [May 19, 2012, 8:58pm UTC](https://discuss.elastic.co/t/strange-result-of-search-children-by-parent/7774/2 "2012-05-19T20:58:51Z")

</div>

I think i found a solution of my problem. Now i send query with preference \_only\_node:xyz where xyz is id master node. When i set \_primary or \_primary\_first result is empty. Why is it necessary to specify node id in preference for right result?

---

<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:28am UTC](https://discuss.elastic.co/t/strange-result-of-search-children-by-parent/7774/3 "2017-07-06T03:28:07Z")

</div>


