# Limit searches to specific shards

**URL:** https://discuss.elastic.co/t/limit-searches-to-specific-shards/5551
**Category:** Elasticsearch
**Created:** [October 10, 2011, 1:25pm UTC](https://discuss.elastic.co/t/limit-searches-to-specific-shards/5551 "2011-10-10T13:25:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jason\_3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jason_3/32/3109_2.png) [@jason\_3](https://discuss.elastic.co/u/jason_3)
#### Post date: [October 10, 2011, 1:25pm UTC](https://discuss.elastic.co/t/limit-searches-to-specific-shards/5551/1 "2011-10-10T13:25:29Z")

</div>

Is it possible to create some sort of client (Transport client, Node  
client or REST) that does either?

1. only searches the shards local to the server the client is  
connected to (for a given index/type/etc)  
OR
2. client specifies which shards the search is limited to (for a given  
index/type/etc).

I don't think the "routing" feature supports limiting a search to a  
specified shard number.

Here is my use case. We would like to use ES as both the index and  
data store. We need to be able to run MapReduce across all the data  
in the datastore periodically. Each node runs ES, a Hadoop DataNode,  
and Hadoop TaskTracker. I want to create a Hadoop InputFormat that is  
truly data local based on the shards. We evaluated wonderdog and it  
works okay, but having truly data local searches would be more  
scalable.

If the client could limit searches to specific shards or limit  
searches to only local shards then I think this would be possible  
since I can determine which shards reside on which machines via (curl -  
s -XGET '[http://localhost:9200/\_cluster/state](http://localhost:9200/_cluster/state)' and equivalent Java  
code).

If this search limiting functionality doesn't exist, would it be  
appropriate for a plugin or is this an internals change that is more  
far reaching?

Thanks,

--Jason

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [October 12, 2011, 6:38pm UTC](https://discuss.elastic.co/t/limit-searches-to-specific-shards/5551/2 "2011-10-12T18:38:16Z")

</div>

Heya,

Got it, It should be simple to add. We already have a preference  
parameter, need to find a good way to express what you are after as a value.  
Open an issue?

-shay.banon

On Mon, Oct 10, 2011 at 3:25 PM, jason [jason.trost@gmail.com](mailto:jason.trost@gmail.com) wrote:

> Is it possible to create some sort of client (Transport client, Node  
> client or REST) that does either?
> 
> 1. only searches the shards local to the server the client is  
> connected to (for a given index/type/etc)  
> OR
> 2. client specifies which shards the search is limited to (for a given  
> index/type/etc).
> 
> I don't think the "routing" feature supports limiting a search to a  
> specified shard number.
> 
> Here is my use case. We would like to use ES as both the index and  
> data store. We need to be able to run MapReduce across all the data  
> in the datastore periodically. Each node runs ES, a Hadoop DataNode,  
> and Hadoop TaskTracker. I want to create a Hadoop InputFormat that is  
> truly data local based on the shards. We evaluated wonderdog and it  
> works okay, but having truly data local searches would be more  
> scalable.
> 
> If the client could limit searches to specific shards or limit  
> searches to only local shards then I think this would be possible  
> since I can determine which shards reside on which machines via (curl -  
> s -XGET '[http://localhost:9200/\_cluster/state](http://localhost:9200/_cluster/state)' and equivalent Java  
> code).
> 
> If this search limiting functionality doesn't exist, would it be  
> appropriate for a plugin or is this an internals change that is more  
> far reaching?
> 
> Thanks,
> 
> --Jason

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [October 12, 2011, 7:11pm UTC](https://discuss.elastic.co/t/limit-searches-to-specific-shards/5551/3 "2011-10-12T19:11:44Z")

</div>

Ok, opened [Search / Get Preference: Add \_only\_node:[node\_id] option · Issue #1388 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1388) and  
pushed the implementation to master. See if it works for you.

On Wed, Oct 12, 2011 at 8:38 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> Heya,
> 
> Got it, It should be simple to add. We already have a preference  
> parameter, need to find a good way to express what you are after as a value.  
> Open an issue?
> 
> -shay.banon
> 
> On Mon, Oct 10, 2011 at 3:25 PM, jason [jason.trost@gmail.com](mailto:jason.trost@gmail.com) wrote:
> 
> > Is it possible to create some sort of client (Transport client, Node  
> > client or REST) that does either?
> > 
> > 1. only searches the shards local to the server the client is  
> > connected to (for a given index/type/etc)  
> > OR
> > 2. client specifies which shards the search is limited to (for a given  
> > index/type/etc).
> > 
> > I don't think the "routing" feature supports limiting a search to a  
> > specified shard number.
> > 
> > Here is my use case. We would like to use ES as both the index and  
> > data store. We need to be able to run MapReduce across all the data  
> > in the datastore periodically. Each node runs ES, a Hadoop DataNode,  
> > and Hadoop TaskTracker. I want to create a Hadoop InputFormat that is  
> > truly data local based on the shards. We evaluated wonderdog and it  
> > works okay, but having truly data local searches would be more  
> > scalable.
> > 
> > If the client could limit searches to specific shards or limit  
> > searches to only local shards then I think this would be possible  
> > since I can determine which shards reside on which machines via (curl -  
> > s -XGET '[http://localhost:9200/\_cluster/state](http://localhost:9200/_cluster/state)' and equivalent Java  
> > code).
> > 
> > If this search limiting functionality doesn't exist, would it be  
> > appropriate for a plugin or is this an internals change that is more  
> > far reaching?
> > 
> > Thanks,
> > 
> > --Jason

---

<div class="post-metadata">

### Author: ![jason\_3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jason_3/32/3109_2.png) [@jason\_3](https://discuss.elastic.co/u/jason_3)
#### Post date: [October 12, 2011, 9:04pm UTC](https://discuss.elastic.co/t/limit-searches-to-specific-shards/5551/4 "2011-10-12T21:04:27Z")

</div>

Awesome. Thanks Shay. I will check this out tomorrow.

On Wed, Oct 12, 2011 at 3:11 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:

> Ok, opened [Search / Get Preference: Add \_only\_node:[node\_id] option · Issue #1388 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1388) and  
> pushed the implementation to master. See if it works for you.
> 
> On Wed, Oct 12, 2011 at 8:38 PM, Shay Banon [kimchy@gmail.com](mailto:kimchy@gmail.com) wrote:
> 
> > Heya,
> > 
> > Got it, It should be simple to add. We already have a preference  
> > parameter, need to find a good way to express what you are after as a value.  
> > Open an issue?
> > 
> > -shay.banon
> > 
> > On Mon, Oct 10, 2011 at 3:25 PM, jason [jason.trost@gmail.com](mailto:jason.trost@gmail.com) wrote:
> > 
> > > Is it possible to create some sort of client (Transport client, Node  
> > > client or REST) that does either?
> > > 
> > > 1. only searches the shards local to the server the client is  
> > > connected to (for a given index/type/etc)  
> > > OR
> > > 2. client specifies which shards the search is limited to (for a given  
> > > index/type/etc).
> > > 
> > > I don't think the "routing" feature supports limiting a search to a  
> > > specified shard number.
> > > 
> > > Here is my use case. We would like to use ES as both the index and  
> > > data store. We need to be able to run MapReduce across all the data  
> > > in the datastore periodically. Each node runs ES, a Hadoop DataNode,  
> > > and Hadoop TaskTracker. I want to create a Hadoop InputFormat that is  
> > > truly data local based on the shards. We evaluated wonderdog and it  
> > > works okay, but having truly data local searches would be more  
> > > scalable.
> > > 
> > > If the client could limit searches to specific shards or limit  
> > > searches to only local shards then I think this would be possible  
> > > since I can determine which shards reside on which machines via (curl -  
> > > s -XGET '[http://localhost:9200/\_cluster/state](http://localhost:9200/_cluster/state)' and equivalent Java  
> > > code).
> > > 
> > > If this search limiting functionality doesn't exist, would it be  
> > > appropriate for a plugin or is this an internals change that is more  
> > > far reaching?
> > > 
> > > Thanks,
> > > 
> > > --Jason

---

<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, 3:52am UTC](https://discuss.elastic.co/t/limit-searches-to-specific-shards/5551/5 "2017-07-06T03:52:12Z")

</div>


