# Sharding by term/facet

**URL:** <https://discuss.elastic.co/t/sharding-by-term-facet/10643>\
**Category:** Elasticsearch\
**Created:** [February 6, 2013, 7:59pm UTC](https://discuss.elastic.co/t/sharding-by-term-facet/10643 "2013-02-06T19:59:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josiah\_Carlson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/josiah_carlson/32/2501_2.png) [@Josiah\_Carlson](https://discuss.elastic.co/u/Josiah_Carlson)\
**Post date:** [February 6, 2013, 7:59pm UTC](https://discuss.elastic.co/t/sharding-by-term-facet/10643/1 "2013-02-06T19:59:42Z")

</div>

Hello,

I've been planning on using ES in a search application, and it could grow  
very quickly, so I've been looking at ways to pre-shard my data.

Now, it turns out that every document that I'm indexing has a list of  
string facets, and all of my searches will have at least one required  
facet, so a natural sharding method would be to shard based on these facets  
(if a document has 7 facets, I would assume that it could be available on 7  
shards).

Questions:  
Is there a way to automatically shard based on facets?  
If so, how? If not, could I write a plugin to do so?  
If I do shard on facets, will routing to the correct shards be done  
automatically, without going to the entire cluster?  
If not, is there a way for me to write a plugin to make this happen?

Thank you,

- Josiah

--  
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:** ![ppearcy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppearcy/32/980_2.png) [@ppearcy](https://discuss.elastic.co/u/ppearcy)\
**Post date:** [February 7, 2013, 6:37am UTC](https://discuss.elastic.co/t/sharding-by-term-facet/10643/2 "2013-02-07T06:37:39Z")

</div>

I think the best you can do is with  
routing([Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/routing-field.html)),  
but that is only a single value per doc.

I would test around how your use case scales.

Best Regards,  
Paul

On Wednesday, February 6, 2013 12:59:42 PM UTC-7, Josiah Carlson wrote:

> Hello,
> 
> I've been planning on using ES in a search application, and it could grow  
> very quickly, so I've been looking at ways to pre-shard my data.
> 
> Now, it turns out that every document that I'm indexing has a list of  
> string facets, and all of my searches will have at least one required  
> facet, so a natural sharding method would be to shard based on these facets  
> (if a document has 7 facets, I would assume that it could be available on 7  
> shards).
> 
> Questions:  
> Is there a way to automatically shard based on facets?  
> If so, how? If not, could I write a plugin to do so?  
> If I do shard on facets, will routing to the correct shards be done  
> automatically, without going to the entire cluster?  
> If not, is there a way for me to write a plugin to make this happen?
> 
> Thank you,
> 
> - Josiah

--  
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:52am UTC](https://discuss.elastic.co/t/sharding-by-term-facet/10643/3 "2017-07-06T02:52:37Z")

</div>


