# How to Limit Search With-In Selected Document ID or Document ID List

**URL:** <https://discuss.elastic.co/t/how-to-limit-search-with-in-selected-document-id-or-document-id-list/21664>\
**Category:** Elasticsearch\
**Created:** [January 15, 2015, 4:50pm UTC](https://discuss.elastic.co/t/how-to-limit-search-with-in-selected-document-id-or-document-id-list/21664 "2015-01-15T16:50:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ATL](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@ATL](https://discuss.elastic.co/u/ATL)\
**Post date:** [January 15, 2015, 4:50pm UTC](https://discuss.elastic.co/t/how-to-limit-search-with-in-selected-document-id-or-document-id-list/21664/1 "2015-01-15T16:50:52Z")

</div>

Use Case: If we have 10 Million documents index on single server in Elastic  
Search in single index, If user want to search but limit search result in  
given 1 Million Doc ID filter so ES only return result within given 1  
million Doc ID filter

When apply search - divide 1 million Doc in 10K doc ID list batches and  
apply with search and loop through all batches On each result return - keep  
merge the result and send one merge result to end user in website

Is there any other better way to do search which get faster result and no  
need do batch search etc if we want to limit search result with in selected  
1 million Doc ID

Thanks  
-V

--

_Notice of Confidentiality_

_This email message and its attachments (if any) are intended solely for  
the use of the addressees hereof. In addition, this message and any  
attachments may contain information that is confidential, privileged and  
exempt from disclosure under applicable law. If you are not the intended  
recipient of this message, you are prohibited from reading, disclosing,  
reproducing, distributing, disseminating or otherwise using this  
transmission. Delivery of this message to any person other than the  
intended recipient is not intended to waive any right or privilege. If you  
have received this message in error, please promptly notify the sender by  
reply email and immediately delete this message from your system._

--  
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/7a0bf27c-f36f-48f8-942c-571158633ac1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7a0bf27c-f36f-48f8-942c-571158633ac1%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [January 18, 2015, 9:33pm UTC](https://discuss.elastic.co/t/how-to-limit-search-with-in-selected-document-id-or-document-id-list/21664/2 "2015-01-18T21:33:09Z")

</div>

Hi,

This use-case typically looks like a join (search within the results of  
another search request) so you should look at whether you can change the  
way that you model your data in order to be able to use nested docs or the  
parent/child functionality. Otherwise, there is no better way,  
elasticsearch does not support general-purpose joins.

On Thu, Jan 15, 2015 at 5:50 PM, ATL [vrajpara@legaldiscoveryllc.com](mailto:vrajpara@legaldiscoveryllc.com) wrote:

> Use Case: If we have 10 Million documents index on single server in  
> Elastic Search in single index, If user want to search but limit search  
> result in given 1 Million Doc ID filter so ES only return result within  
> given 1 million Doc ID filter
> 
> When apply search - divide 1 million Doc in 10K doc ID list batches and  
> apply with search and loop through all batches On each result return - keep  
> merge the result and send one merge result to end user in website
> 
> Is there any other better way to do search which get faster result and no  
> need do batch search etc if we want to limit search result with in selected  
> 1 million Doc ID
> 
> Thanks  
> -V
> 
> _Notice of Confidentiality_
> 
> _This email message and its attachments (if any) are intended solely for  
> the use of the addressees hereof. In addition, this message and any  
> attachments may contain information that is confidential, privileged and  
> exempt from disclosure under applicable law. If you are not the intended  
> recipient of this message, you are prohibited from reading, disclosing,  
> reproducing, distributing, disseminating or otherwise using this  
> transmission. Delivery of this message to any person other than the  
> intended recipient is not intended to waive any right or privilege. If you  
> have received this message in error, please promptly notify the sender by  
> reply email and immediately delete this message from your system._
> 
> --  
> 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/7a0bf27c-f36f-48f8-942c-571158633ac1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7a0bf27c-f36f-48f8-942c-571158633ac1%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/7a0bf27c-f36f-48f8-942c-571158633ac1%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/7a0bf27c-f36f-48f8-942c-571158633ac1%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
Adrien Grand

--  
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/CAL6Z4j7rLKF94s7C%2BNFhgqdQp2yW1A-qLOWJ0zqKFPBhQK8%2BQQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j7rLKF94s7C%2BNFhgqdQp2yW1A-qLOWJ0zqKFPBhQK8%2BQQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:38am UTC](https://discuss.elastic.co/t/how-to-limit-search-with-in-selected-document-id-or-document-id-list/21664/3 "2017-07-06T00:38:09Z")

</div>


