marlonjke
marlonjke

Reputation: 49

ElasticSearch does not accept PUT command to a specific route

I'm trying to implement an rails application on my local machine that uses ElasticSearch. So I installed and used this command to setup ElasticSearch for the application:

curl -XPUT "http://localhost:9200/dev-contacts-v3/_mapping" -d ' { "mappings" : { "_default_" : { "properties" : { " pin" : { "properties" : { "location" : { "type" : "geo_point" } } } } } } } '.

But it returns an error: {"error":"ActionRequestValidationException[Validation Failed: 1: mapping type is missing;]","status":400}

I realized the error only happens when I use the route "http://localhost:9200/dev-contacts-v3/_mapping" with this underline o _mapping.

Does anyone have any idea of the cause of this error?

Upvotes: 0

Views: 71

Answers (1)

paweloque
paweloque

Reputation: 18864

The _mapping function allows you to see the existing mapping for a given index. If you want to define a mapping for a new index you can put a mapping using the index url:

PUT /dev-contacts-v3
{
   "mappings": {
      "_default_": {
         "properties": {
            "pin": {
               "properties": {
                  "location": {
                     "type": "geo_point"
                  }
               }
            }
         }
      }
   }
}

To see the mapping of an index:

GET /dev-contacts-v3/_mapping

On the same level as mappings you can specify settings where you describe the filters, analyzers, etc.. that can be used for you mappings.

Upvotes: 1

Related Questions