elastic/elasticsearch-definitive-guide

A mapping example from the doc, gives `mapper_parsing_exception` error

brugnara opened this issue · 5 comments

Hi.

The example shown in this chapter gives me an error

# this curl works
curl -XDELETE 'localhost:9200/my_store?pretty'

# this gives me the error below
curl -XPUT 'localhost:9200/my_store?pretty' -H 'Content-Type: application/json' -d'
{
    "mappings" : {
        "products" : {
            "properties" : {
                "productID" : {
                    "type" : "string",
                    "index" : "not_analyzed" 
                }
            }
        }
    }
}
'

error:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "No handler for type [string] declared on field [productID]"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "Failed to parse mapping [products]: No handler for type [string] declared on field [productID]",
    "caused_by" : {
      "type" : "mapper_parsing_exception",
      "reason" : "No handler for type [string] declared on field [productID]"
    }
  },
  "status" : 400
}

May be the docs outdated?

Many thanks.

This seems similar to #609 but comes from a different document section.

@brugnara which version was the Elasticsearch version on which you tested this example ?

The string datatype is no longer supported if you're using Elasticearch v6.

See #737.

@tcucchietti yes, as I pointed out, the problem seems to be the outdated doc. I'm on Elastic 6, and following the current doc online I ran into this error. I've also linked the doc section.

Thanks.

You're welcome.

I'm not sure the definitive guide is being maintained since v2.X which is unfortunate.
If somebody stumbles across information about this situation, please share a link :)

Now Instead of Strings, There are two types keyword and text. If you don't want a analysed field use type keyword. For this example I used mapping like below:

curl -X PUT "localhost:9200/my_store" -H 'Content-Type: application/json' -d' { "mappings" : { "products" : { "properties" : { "productID" : { "type" : "keyword", "index" : "true" } } } } } '