# Parent child Query and highlighted result

**URL:** <https://discuss.elastic.co/t/parent-child-query-and-highlighted-result/12205>\
**Category:** Elasticsearch\
**Created:** [May 31, 2013, 11:03am UTC](https://discuss.elastic.co/t/parent-child-query-and-highlighted-result/12205 "2013-05-31T11:03:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![channa\_ly](https://avatars.discourse-cdn.com/v4/letter/c/49beb7/32.png) [@channa\_ly](https://discuss.elastic.co/u/channa_ly)\
**Post date:** [May 31, 2013, 11:03am UTC](https://discuss.elastic.co/t/parent-child-query-and-highlighted-result/12205/1 "2013-05-31T11:03:23Z")

</div>

I am new to search engine. I have started reading elasticsearch for almost  
a month but I have not seen any example similar to the problem I am trying  
to solve. Imagine I have in my mysql database a Case entity that has one  
Employer entity , one Worker entity and many document entity

Case belongs to Worker  
Case belongs to Employer  
Case has\_many Document

Worker has\_many Cases

Employer has\_many Cases

Document belongs\_to Case

My entity is belows

- Case ( number, year, description, employer\_id, worker\_id, documents)
- Worker ( name, position, biography, email, phone)
- Employer (name, country, note, email, phone)
- document ( name, format, full\_path)

For documents entity I use attachment type plugin to index it.

The cases is the most important part of my search . I want to search for  
Cases with any field value in Case, Worker, Employer and Document and  
result should be highlighted accordingly. For example

worker1 ( 'vicheka', 'Garment', 'Some biography', 'vicheka@email.com',  
'855975553553' )  
worker2 ( 'tola', 'Garment', 'Some biography', 'tola@email.com',  
'855128374950' )  
employer1 ( 'NGT group', 'Cambodia', 'some note', 'info@ngt.com',  
'855975512445' )

case1( "001" , 2010, "Some description", worker1.id, employer1.id)  
case2( "002" , 2010, "Some description", worker2.id, employer1.id)

document1 ('evident1.pdf', 'pdf', case1.id )  
document2 ('evident2.docx', 'docx', case1.id )

document3 ('evident1.pdf', 'pdf', case2.id )  
document4 ('evident2.docx', 'docx', case2.id )

When I type "info@ngt.com" the case1 should return :

* * *

Case : 001-2010 vicheka vs NGT group  
From Employer :  
Employer NGT group Cambodia 855975512445 _[info@ngt.com](mailto:info@ngt.com)_

* * *

Case : 002-2010 tola vs NGT group  
From Employer :  
Employer NGT group Cambodia 855975512445 _[info@ngt.com](mailto:info@ngt.com)_

* * *

I am not sure the best way to go with mapping to solve this problem.

Sorry for my bad english. Please feel free to clarify.

I highly appreciate for any help.

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:33am UTC](https://discuss.elastic.co/t/parent-child-query-and-highlighted-result/12205/2 "2017-07-06T02:33:38Z")

</div>


