Home > Net >  Add new suggestion context - ElasticSearch Suggestions
Add new suggestion context - ElasticSearch Suggestions

Time:04-15

I have this search context in my index mapping

Index: region

"place_suggest": {
  "type" : "completion",
  "analyzer" : "simple",
  "preserve_separators" : true,
  "preserve_position_increments" : true,
  "max_input_length" : 50,
  "contexts" : [
    {
      "name" : "place_type",
      "type" : "CATEGORY",
      "path" : "place_type"
    }
  ]
}

And I want to add a new context to this mapping

{
  "name": "restricted",
  "type": "CATEGORY",
  "path": "restricted"
}

I've tried using Update Mapping API to add this new context like this:

PUT region_test/_mapping/
{
  "properties" : {
    "place_suggest" : {
      "contexts": [
        "name": "restricted",
        "type": "CATEGORY",
        "path": "restricted"
      ]
    }
  }
}

I'm using Kibana dev tools for running this query.

CodePudding user response:

You will not be able to edit your field by adding the new context.

You need to create a new mapping and re-index your index.

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#change-existing-mapping-parms

  • Related