简体   繁体   中英

Elasticsearch completion suggester with standard analyzer and numbers

I get an error when trying to index numbers on a completion field with the standard analyser.

Mapping:

PUT music
{
    "mappings": {
        "_doc" : {
            "properties" : {
                "suggest" : {
                    "type" : "completion",
                    "analyzer": "standard"
                }
            }
        }
    }
}

Indexing:

PUT music/_doc/1?refresh
{
  "suggest" : [ 1234, 5678 ]
}

This is the error I get:

[parsing_exception] failed to parse [null]: expected text or object, but got VALUE_NUMBER

Do I have to input strings?

You simply need to put your numbers in double quotes (ie as strings)

PUT music/_doc/1?refresh
{
  "suggest" : [ "1234", "5678" ]
                ^    ^  ^    ^
                |    |  |    |
                 here and here
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM