rudd0211
rudd0211

Reputation: 115

Implement completion suggester on fields in the elasticsearch server

I am trying to implement the completion suggester to my fields in the elasticsearch server. When I try to execute the curl command

curl -X POST localhost:9200/anisug/_suggest?pretty -d '{
 "test" : {
    "text" : "n",
    "completion" : {
        "field" : "header"
    }
}
}'

I get an exception:

ElasticSearchException[Field [header] is not a completion suggest field].

What am I missing out on?

Upvotes: 4

Views: 6150

Answers (1)

aash
aash

Reputation: 1323

I think, while defining the mapping of anisug, you will need to set the header field for completion suggest. For example, you can use this

curl -X PUT localhost:9200/anisug/_mapping -d '{
  "test" : {
        "properties" : {
            "name" : { "type" : "string" },
            "header" : { "type" : "completion",
                          "index_analyzer" : "simple",
                          "search_analyzer" : "simple",
                          "payloads" : true
            }
         }
    }
}'

Similarly, while indexing the data, you'll need to send additional completion information. For more information, visit this link

Upvotes: 5

Related Questions