Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

curl -X POST -d @mapping.json + mapping not created

I am learning elasticsearch. I have specified the mapping in 'mapping.json'. Its contents are

{
    "book" : {
         "_index" : {
             "enabled" : true
         },
         "_id" : {
             "index": "not_analyzed",
             "store" : "yes"
         },
        "properties" : {
            "author" : {
                "type" : "string"
            },
            "characters" : {
                "type" : "string"
            },
            "copies" : {
                "type" : "long",
                "ignore_malformed" : false
            },
            "otitle" : {
                "type" : "string"
            },
            "tags" : {
                "type" : "string"
            },
            "title" : {
                "type" : "string"
            },
            "year" : {
                "type" : "long",
                "ignore_malformed" : false,
                "index" : "analyzed"
            },
            "available" : {
                "type" : "boolean",
                "index" : "analyzed"
            }
        }
    }
}

The present mappings are

$ curl -XGET http://localhost:9200/_mapping?pretty
=> { 
   "development_users" : {
      "user" : {
         "properties" : {
            "email" : {
               "type" : "string"
            },
            "first_name" : {
               "type" : "string"
            },
            "id" : {
               "type" : "string",
               "index" : "not_analyzed",
               "omit_norms" : true,
               "index_options" : "docs",
               "include_in_all" : false
            },
            "last_name" : {
               "type" : "string"
            },
            "role" : {
               "type" : "string"
            }
         }
     }
  }
}

I create mapping for books using the command

$ curl http://localhost:9200/books -X POST -d @mapping.json
=> {"ok":true,"acknowledged":true}

But when list all mappings, i get:

$ curl -XGET http://localhost:9200/_mapping?pretty
=> { "books" : { },
   "development_users" : {
      "user" : {
         "properties" : {
            "email" : {
               "type" : "string"
            },
            "first_name" : {
               "type" : "string"
            },
            "id" : {
               "type" : "string",
               "index" : "not_analyzed",
               "omit_norms" : true,
               "index_options" : "docs",
               "include_in_all" : false
            },
            "last_name" : {
               "type" : "string"
            },
            "role" : {
               "type" : "string"
            }
         }
      }
   }
}

why isnt the mapping for books getting created as specified in mapping.json file?

like image 856
prasad.surase Avatar asked Oct 07 '13 06:10

prasad.surase


1 Answers

Please try this,

curl -XPUT 'http://localhost:9200/<indexname>/book/_mapping' -d @mapping.json
like image 151
Vamsi Krishna Avatar answered Sep 20 '22 15:09

Vamsi Krishna