Morgan
Morgan

Reputation: 395

MapperParsingException when creating mapping for elasticsearch index

Using sense, I'm trying to create a mapping for an index with three properties. When i try to create it i get the following response

{
   "error": "MapperParsingException[Root type mapping not empty after parsing! Remaining fields:   [mappings : {gram={properties={gram={type=string, fields={gram_bm25={type=string, similarity=BM25}, gram_lmd={type=string}}}, sentiment={type=string, index=not_analyzed}, word={type=string, index=not_analyzed}}}}]]",
   "status": 400
}

This is what i have in the sense console

PUT /pos/_mapping/gram
{
  "mappings": {
    "gram": {
      "properties": {
        "gram": {
          "type": "string",
          "fields": {
            "gram_bm25": {
              "type": "string", "similarity": "BM25"
            },
            "gram_lmd": {
              "type": "string"
            }
          }
        },
        "sentiment": {
          "type": "string", "index": "not_analyzed"
        },
        "word": {
          "type": "string", "index": "not_analyzed"
        }
      }
    }
  }
}

Thanks!

Upvotes: 1

Views: 340

Answers (1)

Sloan Ahrens
Sloan Ahrens

Reputation: 8718

You just have the API syntax wrong. You've combined two different methods, basically.

Either create your index, then apply a mapping:

DELETE /pos

PUT /pos

PUT /pos/gram/_mapping
{
   "gram": {
      "properties": {
         "gram": {
            "type": "string",
            "fields": {
               "gram_bm25": {
                  "type": "string",
                  "similarity": "BM25"
               },
               "gram_lmd": {
                  "type": "string"
               }
            }
         },
         "sentiment": {
            "type": "string",
            "index": "not_analyzed"
         },
         "word": {
            "type": "string",
            "index": "not_analyzed"
         }
      }
   }
}

Or do it all at once when you create the index:

DELETE /pos

PUT /pos
{
   "mappings": {
      "gram": {
         "properties": {
            "gram": {
               "type": "string",
               "fields": {
                  "gram_bm25": {
                     "type": "string",
                     "similarity": "BM25"
                  },
                  "gram_lmd": {
                     "type": "string"
                  }
               }
            },
            "sentiment": {
               "type": "string",
               "index": "not_analyzed"
            },
            "word": {
               "type": "string",
               "index": "not_analyzed"
            }
         }
      }
   }
}

Here's the code I used:

http://sense.qbox.io/gist/6d645cc069f5f0fcf14f497809f7f79aff7de161

Upvotes: 1

Related Questions