我有一个索引的以下映射,我在其中进行建议/自动完成查找和响应。
"mappings": {
"listing": {
"_source": {
"enabled": false
},
"dynamic": false,
"properties": {
"_all": {
"enabled": false
},
"listingTitle": {
"type": "completion",
"index_analyzer": "str_index_analyzer",
"search_analyzer": "str_search_analyzer"
},
"address": {
"dynamic": false,
"properties": {
"city": {
"type": "completion",
"index_analyzer": "str_index_analyzer",
"search_analyzer": "str_search_analyzer"
},
"stateOrProvince": {
"type": "completion",
"index_analyzer": "str_index_analyzer",
"search_analyzer": "str_search_analyzer"
}
}
}
}
}
}
这是请求的端点和数据:site.dev:9200/listingsuggest/_suggest
{
"result": {
"text": "Minn",
"completion": {
"field": "address.city"
}
}
}
因此,这适用于查找与以 Minn 开头的城市匹配的文档。我遇到的问题是我还想返回与“Minn”匹配的每个文档的 stateOrProvince 字段值。例如,我的结果集带有以下匹配的单词:
Minneapolis
Minnetonka
我需要它做的是返回这个:
Minneapolis, MN
Minnetonka, MN
目前的完整回应:
{
_shards: {
total: 1
successful: 1
failed: 0
}
result: [{
text: Minn
offset: 0
length: 4
options: [{
text: Minnetonka
score: 1
} {
text: Minneapolis
score: 1
}]
}]
}
如果可能,希望得到完整的答复:
{
_shards: {
total: 1
successful: 1
failed: 0
}
result: [{
text: Minn
offset: 0
length: 4
options: [{
text: Minnetonka, MN
score: 1
} {
text: Minneapolis, MN
score: 1
}]
}]
}
这是可能的,还是该响应的某种变体?