# Template with types having has-parent relationship

**URL:** https://discuss.elastic.co/t/template-with-types-having-has-parent-relationship/44089
**Category:** Elasticsearch
**Created:** [March 10, 2016, 10:10pm UTC](https://discuss.elastic.co/t/template-with-types-having-has-parent-relationship/44089 "2016-03-10T22:10:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![binish12051982](https://avatars.discourse-cdn.com/v4/letter/b/9fc29f/32.png) [@binish12051982](https://discuss.elastic.co/u/binish12051982)
#### Post date: [March 10, 2016, 10:10pm UTC](https://discuss.elastic.co/t/template-with-types-having-has-parent-relationship/44089/1 "2016-03-10T22:10:11Z")

</div>

I am using elasticsearch 1.7.0

My types are as follows  
Account - id, accno,name,address  
Child 1: Contact- name, email  
Child 2: Phone - phno

I am looking for an efficient way of making a search with following needs

1. Apply AND condition on all search strings entered (General search with single text field)
2. If a match is found in child, response should have the following  
Need to return parent  
Child in inner-hits  
Highlight which highlights all search strings
3. If all are matching in parent, just return parent with highlight
4. If match is found in child+parent, response same as 2

---

<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:09pm UTC](https://discuss.elastic.co/t/template-with-types-having-has-parent-relationship/44089/2 "2017-07-05T23:09:20Z")

</div>


