Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Output field in autocomplete suggestion

when I want to index a document in elasticsearch this problem occurring:

message [MapperParsingException[failed to parse]; nested: IllegalArgumentException[unknown field name [output], must be one of [input, weight, contexts]];]

I know that the output field removed from elasticsearch in version 5 but why? and what I have to do for getting single result for inputs?

like image 648
mahdi Avatar asked Dec 26 '16 17:12

mahdi


1 Answers

output field removed from ElasticSearch in version 5, now _source filed returns with the suggestion. Example shown in below.

Mapping

{
    "user": {
        "properties": {
            "name": {
                "type": "string"
            },
            "suggest": {
                "type": "completion",
                "analyzer": "simple",
                "search_analyzer": "simple"
            }
        }
    }
}

Data

{
    "id": "123",
    "name": "Abc",
    "suggest":
    {
        "input": "Abc::123"
    },
    "output": "Abc::123"
}

Query

POST - http://localhost:9200/user*/_suggest?pretty

{
"type-suggest": {
    "text": "Abc",
    "completion": {
        "field": "suggest"
    }
  }
}
like image 76
Sriharitha vusirikala Avatar answered Oct 25 '22 09:10

Sriharitha vusirikala