Routing question


(Daniel Duarte Figueiredo) #1

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:
*
*

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.


(system) #2