# How to return whole group if query succeed for at least one member

**URL:** <https://discuss.elastic.co/t/how-to-return-whole-group-if-query-succeed-for-at-least-one-member/14950>\
**Category:** Elasticsearch\
**Created:** [December 19, 2013, 11:59am UTC](https://discuss.elastic.co/t/how-to-return-whole-group-if-query-succeed-for-at-least-one-member/14950 "2013-12-19T11:59:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Boris\_Kogan](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@Boris\_Kogan](https://discuss.elastic.co/u/Boris_Kogan)\
**Post date:** [December 19, 2013, 11:59am UTC](https://discuss.elastic.co/t/how-to-return-whole-group-if-query-succeed-for-at-least-one-member/14950/1 "2013-12-19T11:59:33Z")

</div>

Hi, All

Please help with the following problem:  
The data is in the following form:  
{  
"id":   
"group\_id":,  
"data\_line": ""  
}

I would like to get all data items with the same group\_id if at least one  
of the data\_line matches the query.  
Is there any way to get results in single query? If now, what is preferred  
way?

Thanks,  
Boris

--  
This message may contain confidential and/or privileged information.  
If you are not the addressee or authorized to receive this on behalf of the  
addressee you must not use, copy, disclose or take action based on this  
message or any information herein.  
If you have received this message in error, please advise the sender  
immediately by reply email and delete this message. Thank you.

--  
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/09385955-729f-43fd-96d9-987e0b0af75c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/09385955-729f-43fd-96d9-987e0b0af75c%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 19, 2013, 3:35pm UTC](https://discuss.elastic.co/t/how-to-return-whole-group-if-query-succeed-for-at-least-one-member/14950/2 "2013-12-19T15:35:21Z")

</div>

Hey,

thats not possible with one query on the top of my head, but should work  
with two queries:

1. Execute your query for data\_line and facet on group\_id with a huge size
2. For each result returned in the facet, execute a query. Group these  
queries in a multi search

Hope this helps... maybe you can save queries by changing the data  
structure.

--Alex

On Thu, Dec 19, 2013 at 12:59 PM, Boris Kogan [borisk@liveperson.com](mailto:borisk@liveperson.com) wrote:

> Hi, All
> 
> Please help with the following problem:  
> The data is in the following form:  
> {  
> "id":   
> "group\_id":,  
> "data\_line": ""  
> }
> 
> I would like to get all data items with the same group\_id if at least one  
> of the data\_line matches the query.  
> Is there any way to get results in single query? If now, what is preferred  
> way?
> 
> Thanks,  
> Boris
> 
> This message may contain confidential and/or privileged information.  
> If you are not the addressee or authorized to receive this on behalf of  
> the addressee you must not use, copy, disclose or take action based on this  
> message or any information herein.  
> If you have received this message in error, please advise the sender  
> immediately by reply email and delete this message. Thank you.
> 
> --  
> 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/09385955-729f-43fd-96d9-987e0b0af75c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/09385955-729f-43fd-96d9-987e0b0af75c%40googlegroups.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/CAGCwEM-kLfzKRSxpXZxr7ZWP0p1Bo\_HfLMPcZr%3DVMBLTAcbLHA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM-kLfzKRSxpXZxr7ZWP0p1Bo_HfLMPcZr%3DVMBLTAcbLHA%40mail.gmail.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:00am UTC](https://discuss.elastic.co/t/how-to-return-whole-group-if-query-succeed-for-at-least-one-member/14950/3 "2017-07-06T02:00:10Z")

</div>


