venkat
venkat

Reputation: 73

ElasticsearchIllegalArgumentException

My code is

curl -XGET 'http://localhost:9200/web/_suggest?pretty' -d '
{ "brand-suggest": {"completion": {"field": "nameSuggest","size":   "5","context": { "private": "false" }}, "text": "sampl"}}'

I have an error while trying in elasticsearch suggest query.

"index" : "webpage",
      "shard" : 4,
      "status" : 500,
      "reason" : "BroadcastShardOperationFailedException[[tellofy][4] ];  nested: ElasticsearchException[failed to execute suggest]; nested: ElasticsearchIllegalArgumentException[suggester [completion] doesn't expect any context]; "
    }

What is the reason for the above error. I can't able to find the cause of that error.

Upvotes: 0

Views: 1074

Answers (1)

Val
Val

Reputation: 217564

nameSuggest has a completion type but without context, so your suggest query is not allowed to specify a context

See the difference between normal completion fields and completion fields with context

If you wish to run the following query

curl -XGET 'http://localhost:9200/web/_suggest?pretty' -d '{
  "brand-suggest": {
    "completion": {
      "field": "nameSuggest",
      "size": "5",
      "context": {
        "private": "false"
      }
    },
    "text": "sampl"
  }
}'

You need to change the mapping of your nameSuggest field to this i.e. add a context configuration section:

{
  "type": "completion",
  "analyzer": "simple",
  "search_analyzer": "simple",
  "context": {
    "private": {
      "type": "category",
      "path": "private"
    }
  }
}

Upvotes: 1

Related Questions