Question re implementing routing


(Gerald DeConto) #1

I am having some issues implementing routing in an index I am working on, and would really appreciate some help.

After implementing routing in the schema, I created a new index with that schema and populated it. When I check the mapping using "GET myindex/mytype/_mapping", I see the routing configuration and it appears (to me) to be properly set up.

The routing field is called identifiers.state_code and it a string and contains a state code value for each document.

Since I didn't define a specific analyser, ElasticSearch should automatically configure it as a full-text string field and analyze it with the standard analyzer, which includes lower-casing (this per the documentation)

However, routing does not appear to be working as the following two queries return different results:

GET myindex/_search?routing=ar
GET myindex/_search?routing=AR

The lowercase version of the command doesn't even return the routing value I am specified (found this when I added faceting of the state code values to the command to see the various values).

Can anyone tell me what I am doing wrong with the routing configuration? Any and all help appreciated.

Here is a snippet (to keep it short) from the results of running "GET myindex/mytype/_mapping":

{
"myindex": {
"mappings": {
"mytype": {
"_all": {
"enabled": false
},
"_id": {
"path": "id"
},
"_routing": {
"required": true,
"path": "identifiers.state_code"
},
"_timestamp": {
"enabled": true
},
"_index": {
"enabled": true
},
"properties": {
"identifiers": {
"properties": {
"primary_id": {
"type": "long"
},
"state_code": {
"type": "string",
"norms": {
"enabled": false
}
},
...
}
},
...


(Gerald DeConto) #2

note:

I do understand that GET myindex/_search?routing=ar and GET myindex/_search?routing=AR would produce different results if the values in identifiers.state_code were different; ie docs with state_code=ar would go in one shard and docs with state_code=AR may go into another shard

my concern is that the routing values in identifiers.state_code should always be lowercased (due to standard analyzer being default for string values), so I should only get results for GET myindex/_search?routing=ar

It looks like when indexing the docs, routing uses the unanalyzed values in identifiers.state_code.

Is that correct?


(system) #3