# Partial string match for nested value

**URL:** <https://discuss.elastic.co/t/partial-string-match-for-nested-value/32040>\
**Category:** Elasticsearch\
**Created:** [October 12, 2015, 8:43pm UTC](https://discuss.elastic.co/t/partial-string-match-for-nested-value/32040 "2015-10-12T20:43:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tommc3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tommc3/32/4300_2.png) [@tommc3](https://discuss.elastic.co/u/tommc3)\
**Post date:** [October 12, 2015, 8:43pm UTC](https://discuss.elastic.co/t/partial-string-match-for-nested-value/32040/1 "2015-10-12T20:43:40Z")

</div>

If I have a document like this

{  
"owner": {  
"name": "joe",  
"pet": {  
"name": "rover",  
"type": "dog"  
}  
}  
}

And I want to search on all dogs with a name that starts with ro how could create a nested query on multiple fields?

I think I would query for some fields using a term query and other fields as a wildcard. Or maybe use ngram?

---

<div class="post-metadata">

**Author:** ![John\_D\_Ament](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/john_d_ament/32/764_2.png) [@John\_D\_Ament](https://discuss.elastic.co/u/John_D_Ament)\
**Post date:** [October 17, 2015, 1:50am UTC](https://discuss.elastic.co/t/partial-string-match-for-nested-value/32040/2 "2015-10-17T01:50:30Z")

</div>

I would probably first do a filter query on owner.pet.type = dog and then perform the query against owner.pet.name using a match query. You should probably set your mapping on type to be an exact match, but make owner.pet.name support ngrams. If you explicitly want start use prefix.

---

<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 5, 2017, 11:44pm UTC](https://discuss.elastic.co/t/partial-string-match-for-nested-value/32040/3 "2017-07-05T23:44:14Z")

</div>


