About display field routing


(Yuhan) #1

Hi all,

I'm trying to create an index with field routing.
http://www.elasticsearch.org/guide/reference/mapping/routing-field.html

I already had the index has existed for a while without routing,
can I add field routing without rebuild the index? (example please..)

Another problem where should I put "_routing" settings?

My index is named "sources", and the indexType is named "video".
should I put it inside "mappings", inside "video", or inside "sources"?
(I assume it should go inside "video", as it is a field with "store/index"
options as mentioned in the documentation.
however, the example makes me feel it should go under the indexName
"sources":

"comment" : {
"_routing" : {
"required" : true,
"path" : "blog.post_id"

)

(The example also confused me as having no ' index' : 'not_analyzed',
'store': 'yes' inside _routing, I assume they are the default value)

Here's how I did it:

curl -XPOST localhost:9200/sources -d '{

"mappings" : {
    "video" : {
        "_routing" : {
        "required" : true,
        "path" : "video.id"
     },
        "properties" : {

    "id" : {
      "type" : "integer",
      "ignore_malformed" : false
    },
   ...

Is this right?

in order to verify the index routing, how do I display the field _routing
on an index?

Thank you.

Yuhan

--


(Yuhan) #2

to answer my own question, I changed "path" : "id" and listed "_routing"
aside of "properties",
and it worked. verified the shard number to be consistent through the java
client.

curl -XPOST localhost:9200/sources -d '{

"mappings" : {
    "video" : {
        "_routing" : {
        "required" : true,
        "path" : "id <http://video.id>"
     },
        "properties" : {

    "id" : {
      "type" : "integer",
      "ignore_malformed" : false
    },
   ...

Thank you.

Yuhan

On Tue, Oct 9, 2012 at 3:39 PM, Yuhan Zhang yzhang@onescreen.com wrote:

Hi all,

I'm trying to create an index with field routing.
http://www.elasticsearch.org/guide/reference/mapping/routing-field.html

I already had the index has existed for a while without routing,
can I add field routing without rebuild the index? (example please..)

Another problem where should I put "_routing" settings?

My index is named "sources", and the indexType is named "video".
should I put it inside "mappings", inside "video", or inside "sources"?
(I assume it should go inside "video", as it is a field with "store/index"
options as mentioned in the documentation.
however, the example makes me feel it should go under the indexName
"sources":

"comment" : {

    "_routing" : {

        "required" : true,

        "path" : "blog.post_id"

)

(The example also confused me as having no ' index' : 'not_analyzed',
'store': 'yes' inside _routing, I assume they are the default value)

Here's how I did it:

curl -XPOST localhost:9200/sources -d '{

"mappings" : {
    "video" : {
        "_routing" : {
        "required" : true,
        "path" : "video.id"
     },
        "properties" : {

    "id" : {
      "type" : "integer",
      "ignore_malformed" : false
    },
   ...

Is this right?

in order to verify the index routing, how do I display the field _routing
on an index?

Thank you.

Yuhan

--


(system) #3