mahdi
mahdi

Reputation: 972

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?

Upvotes: 7

Views: 1558

Answers (2)

Glenn Van Schil
Glenn Van Schil

Reputation: 1099

Elastic mentions the following

As suggestions are document-oriented, suggestion metadata (e.g. output) should now be specified as a field in the document. The support for specifying output when indexing suggestion entries has been removed. Now suggestion result entry’s text is always the un-analyzed value of the suggestion’s input (same as not specifying output while indexing suggestions in pre-5.0 indices).

Source

Update

I was able to get a single output from multiple inputs in ES 5.1.1. You can find the answere here

Upvotes: 1

Sriharitha vusirikala
Sriharitha vusirikala

Reputation: 21

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"
    }
  }
}

Upvotes: 1

Related Questions