# Routing in Elasticsearch

**URL:** <https://discuss.elastic.co/t/routing-in-elasticsearch/17439>\
**Category:** Elasticsearch\
**Created:** [May 9, 2014, 9:34pm UTC](https://discuss.elastic.co/t/routing-in-elasticsearch/17439 "2014-05-09T21:34:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rajagopal\_Sathyamurt](https://avatars.discourse-cdn.com/v4/letter/r/46a35a/32.png) [@Rajagopal\_Sathyamurt](https://discuss.elastic.co/u/Rajagopal_Sathyamurt)\
**Post date:** [May 9, 2014, 9:34pm UTC](https://discuss.elastic.co/t/routing-in-elasticsearch/17439/1 "2014-05-09T21:34:23Z")

</div>

I have a question about how to best perform routing. We have three types of  
data that we are indexing -- entities, user\_entity\_relationships, and  
user\_entity\_analytics. This is mapped as a parent, child, grand child  
relationship. Entities being the parent - which can have multiple  
user\_entity\_relationships as children (each user\_entity\_relationship  
belongs to one user) and user\_entity\_analytics being the grandchild. An  
entity can have multiple user\_entity\_relationships as children for each  
user it belongs to. User\_entity\_relationship can have multiple  
user\_entity\_analytics as children - one for each day.

I've read about the importance of custom routing scheme and the general  
recommendation seems to be to use user based routing scheme. However, in  
our specific case, user based routing doesn't work because entities (the  
parent) can belong to multiple users. By default, the child gets routed to  
the same shard as the parent. But in our case, we have one or more children  
for each parent and the user information is bound to the child and not to  
the parent.

Some common operations that we need to perform are

1. Searching on all entities belonging to a specific user over a certain  
date range (the date is stored inside entity)

2. Perform aggregates on entity analytics for a specific user over a date  
range,

3. perform aggregates on entity data for a user over a date range.

It would be great is anyone can advise me on best practices for indexing as  
well as routing this kind of data.

--  
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/1d40fe50-4e7f-4687-913f-1219e91b8b09%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1d40fe50-4e7f-4687-913f-1219e91b8b09%40googlegroups.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, 1:30am UTC](https://discuss.elastic.co/t/routing-in-elasticsearch/17439/2 "2017-07-06T01:30:24Z")

</div>

Closed on July 6, 2017, 1:30am UTC


