elasticsearch - 弹性 match_phrase_prefix 设置单词顺序
问题描述
无法找到一种干净的方式来执行这种类型的查询——有没有办法指定这些前缀只返回带有单词前缀的结果?这样一个有效的回报将是 Alpha Beta 并且 Beta Alpha 不会返回?
"query": {
"bool": {
"must": [
{
"match_phrase_prefix": {
"search_name": "Al"
}
},
{
"match_phrase_prefix": {
"search_name": "Be"
}
}
]
}
},
解决方案
如果您已索引keyword
该字段的 -type 版本,则可以执行以下操作:
"query": {
"bool": {
"must": [
{
"match_phrase_prefix": {
"search_name.keyword": "Al"
}
},
{
"match_phrase_prefix": {
"search_name.keyword": "Be"
}
}
]
}
}
推荐阅读
- python - 如何在for循环中将数据框附加到不同的Excel工作表
- android - 强制停止由 Firebase 安装的 mod APK 应用程序
- node.js - 当有人使用跳过功能时保持歌曲音量的不和谐机器人
- javascript - 每次渲染都没有更新内容
- android - Flutter / Firebase RTDB Listener 在订阅取消并退出后仍处于活动状态
- node.js - socket.io 在连接时加入多个房间
- python - Geopy 不提供长度为 4 位的邮政编码
- nuxt.js - NuxtJS2:在 Nuxt 模块中使用时不推荐使用正文解析器
- javascript - 防止 mqtt.js 在浏览器中断开连接
- amazon-web-services - 无法将 OVA 文件导入 AWS