# Matching on sibling json nodes?

**URL:** <https://discuss.elastic.co/t/matching-on-sibling-json-nodes/17458>\
**Category:** Elasticsearch\
**Created:** [May 12, 2014, 11:42am UTC](https://discuss.elastic.co/t/matching-on-sibling-json-nodes/17458 "2014-05-12T11:42:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![krosenvold](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krosenvold/32/44880_2.png) [@krosenvold](https://discuss.elastic.co/u/krosenvold)\
**Post date:** [May 12, 2014, 11:42am UTC](https://discuss.elastic.co/t/matching-on-sibling-json-nodes/17458/1 "2014-05-12T11:42:15Z")

</div>

We're submitting a json document that looks like this:

{  
"book": {  
"title" : "book1",  
"authors": [  
{"name":"auth1", "role":"role1"},  
{"name":"auth2", "role":"role2"}  
]  
}  
}

We would like to do searches that find this for a search on auth1/role1 but  
_not_ for auth1/role2. We have used nested queries to make this work, but  
unfortunately nested queries dont work with highlighting. Is there any  
other way to accomplish this ? (We are contemplating simply filing a new  
field that combines name and role, but that would also have some drawbacks).

Kristian

--  
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/0b062a6d-5766-4dee-96a5-27aff637f56b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0b062a6d-5766-4dee-96a5-27aff637f56b%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [May 12, 2014, 12:36pm UTC](https://discuss.elastic.co/t/matching-on-sibling-json-nodes/17458/2 "2014-05-12T12:36:16Z")

</div>

Hi Kristian

You can use nested objects and set "include\_in\_parent" to true (it's like  
using type:nested and type:object on the same field), then highlight on the  
fields in the parent object.

clint

On 12 May 2014 13:42, Kristian Rosenvold [kristian.rosenvold@gmail.com](mailto:kristian.rosenvold@gmail.com)wrote:

> We're submitting a json document that looks like this:
> 
> {  
> "book": {  
> "title" : "book1",  
> "authors": [  
> {"name":"auth1", "role":"role1"},  
> {"name":"auth2", "role":"role2"}  
> ]  
> }  
> }
> 
> We would like to do searches that find this for a search on auth1/role1  
> but _not_ for auth1/role2. We have used nested queries to make this work,  
> but unfortunately nested queries dont work with highlighting. Is there any  
> other way to accomplish this ? (We are contemplating simply filing a new  
> field that combines name and role, but that would also have some drawbacks).
> 
> Kristian
> 
> --  
> 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/0b062a6d-5766-4dee-96a5-27aff637f56b%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0b062a6d-5766-4dee-96a5-27aff637f56b%40googlegroups.com)[https://groups.google.com/d/msgid/elasticsearch/0b062a6d-5766-4dee-96a5-27aff637f56b%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/0b062a6d-5766-4dee-96a5-27aff637f56b%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/CAPt3XKSJ%3Dq2-koCpKd3ALdyw9eHVfb0RRmDm3PwZ\_Ln%2BZ0-UOg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPt3XKSJ%3Dq2-koCpKd3ALdyw9eHVfb0RRmDm3PwZ_Ln%2BZ0-UOg%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, 1:30am UTC](https://discuss.elastic.co/t/matching-on-sibling-json-nodes/17458/3 "2017-07-06T01:30:10Z")

</div>

Closed on July 6, 2017, 1:30am UTC


