pluxxoglosswratE
pluxxoglosswratE

Reputation: 3

Elasticsearch 5.2 Context Suggester Type Definition - Error

I am having problems defining a Context Suggester in Elasticsearch 5.2

This is how I try to do it:

curl -XPUT 'localhost:9200/world/port/_mapping' -d '{
"port": {

"properties": {
   "name": {
      "type": "string"
   },
   "suggest": {
      "type": "completion",
      "analyzer": "simple",
      "payloads": true,
      "preserve_separators": true,
      "preserve_position_increments": true,
      "max_input_length": 50,
      "contexts": {
         "type": {
            "name": "port_type",
            "type": "category",
            "path": "name"
         }
      }
   }
}

}
}'

I played around with the parameters, but it always ends up with error:

{
"error":
{
"root_cause":
  [{"type":"parse_exception","reason":"missing [name] in context mapping"}],
"type":"parse_exception","reason":"missing [name] in context mapping"
},
"status":400
}

I tried to solve it by googling, but to no success.

What is the name the message is referring to?

Can you help me?

Upvotes: 0

Views: 174

Answers (1)

Pavel Vasilev
Pavel Vasilev

Reputation: 1042

Here are couple moments:

  • context should be a JSON array
  • its elements should be just JSON dictionaries
  • Btw, what is "payload": true - I believe it is one more item which can be eliminated as unnecessary.

After digging into that a little bit I've made it happen with the following command:

curl -XPUT 'localhost:9200/world' -d '
{
  "mappings" : {
    "port": {
      "properties": {
        "name": {
          "type": "string"
        },
        "suggest": {
          "type": "completion",
          "analyzer": "simple",
          "preserve_separators": true,
          "preserve_position_increments": true,
          "max_input_length": 50,
          "contexts": [
            {
              "name": "port_type",
              "type": "category",
              "path": "name"
            }
          ]
        }
      }
    }
  }
}'

Upvotes: 1

Related Questions