Elasticsearch 補完サジェスターを使用すると、1 単語のクエリに一致する複数単語の入力候補を返す際に問題が発生します。
構造例:
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"
]
}
}
作業クエリ:
POST /test_index/_suggest
{
"test_suggest":{
"text":"cat",
"completion": {
"field" : "test_suggest"
}
}
}
結果で
{
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"test_suggest": [
{
"text": "cat",
"offset": 0,
"length": 3,
"options": [
{
"text": "cat dog",
"score": 1
}
]
}
]
}
失敗したクエリ:
POST /test_index/_suggest
{
"test_suggest":{
"text":"dog",
"completion": {
"field" : "test_suggest"
}
}
}
結果で
{
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"test_suggest": [
{
"text": "dog",
"offset": 0,
"length": 3,
"options": []
}
]
}
「cat dog」に一致する作業クエリと同じ結果が期待されます。問題の内容と、失敗したクエリを機能させる方法について何か提案はありますか? 空白アナライザーの代わりに標準アナライザーを使用すると、同じ結果が得られます。上記の例のように、入力文字列ごとに複数の単語を使用したいと考えています。