# Routing question

**URL:** <https://discuss.elastic.co/t/routing-question/8304>\
**Category:** Elasticsearch\
**Created:** [July 4, 2012, 1:10am UTC](https://discuss.elastic.co/t/routing-question/8304 "2012-07-04T01:10:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Duarte\_Figuei](https://avatars.discourse-cdn.com/v4/letter/d/49beb7/32.png) [@Daniel\_Duarte\_Figuei](https://discuss.elastic.co/u/Daniel_Duarte_Figuei)\
**Post date:** [July 4, 2012, 1:10am UTC](https://discuss.elastic.co/t/routing-question/8304/1 "2012-07-04T01:10:52Z")

</div>

Hello,  
I have a doubt about using "routing" when indexing/searching. I'm indexing  
documents called "activities" like this one:  
{  
"\_index" : "activity\_index",  
"\_type" : "activity",  
"\_id" : "4\_18\_8",  
"\_score" : 1.0, "\_source" : {  
"id": "4\_18\_8",  
"actorId": 4,  
"objectId": 18,  
"type": 8,  
"date": "2012-07-02T10:57:13.6849786-03:00",  
"originalActionDate": "0001-01-01T00:00:00"  
} }

When I index these documents, I use the "actorId" field as the routing  
value. The Id field is a combination of the other fields (actorId, objectId  
and type), as you can see. When I want to list the activities of a specific  
actor, I search using the actorId as the routing value, again. But when I  
try to get a document by the ID, for example:  
\*  
\*

- curl [http://USER:PASS@192.168.0.13:8080/activity\_index/activity/4\_18\_8\*](http://USER:PASS@192.168.0.13:8080/activity_index/activity/4_18_8*)
- 
- 

I get nothing.  
\*  
\*  
\*  
{"\_index":"activity\_index","\_type":"activity","\_id":"4\_18\_8","exists":false}  
\*  
\*  
\*  
My question is: if I use the routing field when indexing, the only way I  
can retrieve my documents is specifying it again? Can't I get the element  
by Id or list them using a filter if I don't have the actorId?

In my case, I think I could just split the id and use the first number as  
the routing value, but I want to understand more about routing and when to  
use it. Also, I don't know how to define the routing value when getting a  
document by ID. I have had similar problems in cases where I was indexing  
texts and my id was an auto increment number and the routing value was the  
"author" field and I couldn't get a list of those texts by id, and there  
wasn't the option of trying to split the id to find the routing value. I  
tried to use routing to improve searching since in a lot of situations I  
need to find the activities by the actorId or the texts by the authorId.

---

<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:21am UTC](https://discuss.elastic.co/t/routing-question/8304/2 "2017-07-06T03:21:36Z")

</div>


