Routing question

Hi all!

I'm newbie in elastic, please advice. I set up elastic v.0.19.11 on two VMs, summary I have 2 shards one on each VM. My mapping is:
http://10.112.1.10:9200/search/test/_mapping/?pretty=true
{
"test" : {
"_all" : {
"enabled" : false
},
"_id" : {
"path" : "RecordID"
},
"_routing" : {
"required" : true
},
"_source" : {
"enabled" : false
},
"properties" : {
"Date" : {
"type" : "date",
"index" : "analyzed",
"store" : "yes",
"format" : "date_time_no_millis"
},
"Name" : {
"type" : "string",
"analyzer" : "standard",
"store" : "yes"
},
"RecordID" : {
"type" : "string",
"index" : "not_analyzed",
"store" : "yes"
}
}
}
}

I'm using bulk indexing with meta like {"index":{ "_routing": 20121216 }} and {"index":{ "_routing": 20121217 }}.
My question is: when I run queries like
http://10.112.1.10:9200/search/test/_search/?q=:&fields=RecordID,_routing&size=1&pretty=true&routing=20121217
I get
{
"took" : 47,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 453184,
"max_score" : 1.0,
"hits" : [ {
"_index" : "search",
"_type" : "test",
"_id" : "16870466180",
"_score" : 1.0,
"fields" : {
"RecordID" : "16870466180",
"_routing" : "20121217"
}
} ]
}
}
or
http://10.112.1.10:9200/search/test/_search/?q=:&fields=RecordID,_routing&size=1&pretty=true&routing=20121216
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "search",
"_type" : "test",
"_id" : "1",
"_score" : 1.0,
"fields" : {
"RecordID" : "1",
"_routing" : "20121216"
}
} ]
}
}
seems looks fine. But when I tun, for example,
http://10.112.1.10:9200/search/test/_search/?q=:&fields=RecordID,_routing&size=1&pretty=true&routing=abcd
I get
{
"took" : 5,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 453184,
"max_score" : 1.0,
"hits" : [ {
"_index" : "search",
"_type" : "test",
"_id" : "16870466180",
"_score" : 1.0,
"fields" : {
"RecordID" : "16870466180",
"_routing" : "20121217"
}
} ]
}
}

Is it normal or I'm doing something wrong? Maybe this query mustn't return any results?

Thanks

Dennis,

Routing values are used as hash values to determine which shard to store
the document on.
During the index operation, using the same routing therefore guarantees
documents will always be placed on the same shard. However, 2 different
routing do not necessarily reference 2 different shards.
I would guess that "20121217" and "abcd" end up referencing the same shard.

As far as searching goes, search using routing does NOT only return
documents that were stored with the specified routing. It uses the
specified routing to determine which shards to execute the search on.

See more information about search and routing here:

Since you search is open-ended, it returns all documents in the shard(s)
associated with routing abcd (or 20121217).

Andreas

On Monday, December 17, 2012 9:28:50 AM UTC-7, dennis yermakov wrote:

Hi all!

I'm newbie in elastic, please advice. I set up elastic v.0.19.11 on two
VMs,
summary I have 2 shards one on each VM. My mapping is:
http://10.112.1.10:9200/search/test/_mapping/?pretty=true
{
"test" : {
"_all" : {
"enabled" : false
},
"_id" : {
"path" : "RecordID"
},
"_routing" : {
"required" : true
},
"_source" : {
"enabled" : false
},
"properties" : {
"Date" : {
"type" : "date",
"index" : "analyzed",
"store" : "yes",
"format" : "date_time_no_millis"
},
"Name" : {
"type" : "string",
"analyzer" : "standard",
"store" : "yes"
},
"RecordID" : {
"type" : "string",
"index" : "not_analyzed",
"store" : "yes"
}
}
}
}

I'm using bulk indexing with meta like {"index":{ "_routing": 20121216 }}
and {"index":{ "_routing": 20121217 }}.
My question is: when I run queries like

http://10.112.1.10:9200/search/test/_search/?q=*:*&fields=RecordID,_routing&size=1&pretty=true&routing=20121217
I get
{
"took" : 47,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 453184,
"max_score" : 1.0,
"hits" : [ {
"_index" : "search",
"_type" : "test",
"_id" : "16870466180",
"_score" : 1.0,
"fields" : {
"RecordID" : "16870466180",
"_routing" : "20121217"
}
} ]
}
}
or

http://10.112.1.10:9200/search/test/_search/?q=*:*&fields=RecordID,_routing&size=1&pretty=true&routing=20121216
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
"_index" : "search",
"_type" : "test",
"_id" : "1",
"_score" : 1.0,
"fields" : {
"RecordID" : "1",
"_routing" : "20121216"
}
} ]
}
}
seems looks fine. But when I tun, for example,

http://10.112.1.10:9200/search/test/_search/?q=*:*&fields=RecordID,_routing&size=1&pretty=true&routing=abcd
I get
{
"took" : 5,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 453184,
"max_score" : 1.0,
"hits" : [ {
"_index" : "search",
"_type" : "test",
"_id" : "16870466180",
"_score" : 1.0,
"fields" : {
"RecordID" : "16870466180",
"_routing" : "20121217"
}
} ]
}
}

Is it normal or I'm doing something wrong? Maybe this query mustn't return
any results?

Thanks

--
View this message in context:
http://elasticsearch-users.115913.n3.nabble.com/Routing-question-tp4027080.html
Sent from the Elasticsearch Users mailing list archive at Nabble.com.

--

andreasch, many thanks for your help! seems I understand how it works!