Search code examples
elasticsearchelasticsearch-mapping

ElasticSearch Failed to parse mapping


I am trying to create new index with put request http://localhost:9200/songs with following mapping

{
"mappings": {
    "songs": {
        "properties": {
            "artist_name": {
                "type": "text"
            },
            "songs": {
                "type": "nested",
                "properties": {
                    "name": {
                        "type": "keyword"
                    },
                    "lyric": {
                        "type": "keyword"
                    }
                }
            }
        }
    }
}

}

Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [songs : {properties={artist_name={type=text}, songs={type=nested, properties={lyric={type=keyword}, name={type=keyword}}}}}]"

The json structure is valid. Where am I wrong?


Solution

  • You seem to be using ES version 7 where the type has been deprecated as mentioned here:

    Change your mapping to the below and it should work.

    PUT <your_index_name>
    {
      "mappings": {
        "properties": {
          "artist_name": {
            "type": "text"
          },
          "songs": {
            "type": "nested",
            "properties": {
              "name": {
                "type": "keyword"
              },
              "lyric": {
                "type": "keyword"
              }
            }
          }
        }
      }
    }
    

    Hope this helps!