# Joining the results to another

**URL:** <https://discuss.elastic.co/t/joining-the-results-to-another/136800>\
**Category:** Elasticsearch\
**Created:** [June 21, 2018, 8:36am UTC](https://discuss.elastic.co/t/joining-the-results-to-another/136800 "2018-06-21T08:36:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![akash9886](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akash9886/32/32531_2.png) [@akash9886](https://discuss.elastic.co/u/akash9886)\
**Post date:** [June 21, 2018, 8:36am UTC](https://discuss.elastic.co/t/joining-the-results-to-another/136800/1 "2018-06-21T08:36:23Z")

</div>

My documents look like below,  
{  
"took": 22,  
"timed\_out": false,  
"\_shards": {  
"total": 1,  
"successful": 1,  
"failed": 0  
},  
"hits": {  
"total": 88096,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "elasticray\_20155",  
"\_type": "documents",  
"\_id": "thread\_1",  
"\_score": 1,  
"\_source": {  
"entryClassPK": "thread\_1",  
"entryClassName": "MBThread",  
}  
},  
{  
"\_index": "elasticray\_20155",  
"\_type": "documents",  
"\_id": "thread\_2",  
"\_score": 1,  
"\_source": {  
"entryClassPK": "thread\_2",  
"entryClassName": "MBThread",  
}  
},  
{  
"\_index": "liferay\_elasticray\_20155",  
"\_type": "documents",  
"\_id": "message\_1",  
"\_score": 1,  
"\_source": {  
"entryClassPK": "message\_1",  
"entryClassName": "MBMessage",  
"title":"test message aaa",  
"threadID":"thread\_1"  
}  
},  
{  
"\_index": "liferay\_elasticray\_20155",  
"\_type": "documents",  
"\_id": "message\_2",  
"\_score": 1,  
"\_source": {  
"entryClassPK": "message\_2",  
"entryClassName": "MBMessage",  
"title":"test message bbb",  
"threadID":"thread\_2"  
}  
},  
{  
"\_index": "liferay\_elasticray\_20155",  
"\_type": "documents",  
"\_id": "message\_3",  
"\_score": 1,  
"\_source": {  
"entryClassPK": "message\_3",  
"entryClassName": "MBMessage",  
"title":"test message ccc",  
"threadID":"thread\_1"  
}  
}  
]  
}  
}

I want to search in title where entryClassName is MBMessage,  
But in return i need the set of documents where entryClassName is MBThread +(entryClassPK == threadID results of search)

is it possible ?

---

<div class="post-metadata">

**Author:** ![akash9886](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/akash9886/32/32531_2.png) [@akash9886](https://discuss.elastic.co/u/akash9886)\
**Post date:** [June 21, 2018, 11:12am UTC](https://discuss.elastic.co/t/joining-the-results-to-another/136800/2 "2018-06-21T11:12:13Z")

</div>

I am Using below query , where i get the list of threadid, but i need the whole document of it.  
Where thread id is entryClassPk ,

GET elasticray\_20155/\_search  
{  
"size": 0,  
"query": {  
"query\_string": {  
"query": "+(entryClassName:MBMessage)+(title:test)"  
}  
},  
"aggs":{  
"threads":{  
"terms" : { "field" : "threadId", "size" : 10}  
}  
}  
}

can somebody help how can i go forward.,?

---

<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 19, 2018, 11:12am UTC](https://discuss.elastic.co/t/joining-the-results-to-another/136800/3 "2018-07-19T11:12:25Z")

</div>

Closed on July 19, 2018, 11:12am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
