Using the Elasticsearch completion suggester I have problems returning multi-word input suggestions matching a one-word query.
Example structure:
PUT /test_index/
{
"mappings": {
"item": {
"properties": {
"test_suggest": {
"type": "completion",
"index_analyzer": "whitespace",
"search_analyzer": "whitespace",
"payloads": false
}
}
}
}
}
PUT /test_index/item/1
{
"test_suggest": {
"input": [
"cat dog",
"elephant"
]
}
}
Working query:
POST /test_index/_suggest
{
"test_suggest":{
"text":"cat",
"completion": {
"field" : "test_suggest"
}
}
}
with result
{
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"test_suggest": [
{
"text": "cat",
"offset": 0,
"length": 3,
"options": [
{
"text": "cat dog",
"score": 1
}
]
}
]
}
Failing query:
POST /test_index/_suggest
{
"test_suggest":{
"text":"dog",
"completion": {
"field" : "test_suggest"
}
}
}
with result
{
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"test_suggest": [
{
"text": "dog",
"offset": 0,
"length": 3,
"options": []
}
]
}
I would expect the same result as the working query, matching 'cat dog'. Any suggestions what the problem is and how to make the failing query working? I get the same results when using the standard analyzer instead of the whitespace analyzer. I would like to use multiple words per input string as showed in the example above.