【发布时间】:2020-12-03 04:07:32
【问题描述】:
我想从弹性搜索中搜索数据,其中数据从开头的前 n 个字符开始匹配。
下面是我在 ES 索引中的数据集/数据
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 47,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "search_suggestions",
"_type": "_doc",
"_id": "VW5pdGVkIFN0YXRlcw==",
"_score": 1,
"_source": {
"id": "VW5pdGVkIFN0YXRlcw==",
"name": "India",
}
},
{
"_index": "search_suggestions",
"_type": "_doc",
"_id": "RW1iYXNzeSBvZiB0aGUgViwgREMsIFVTQQ==",
"_score": 1,
"_source": {
"id": "RW1iYXNzeSBvZiB0aGUgViwgREMsIFVTQQ",
"name": "Maharashtra, India",
}
},
{
"_index": "search_suggestions",
"_type": "_doc",
"_id": "TWFoaSBCYXpB",
"_score": 1,
"_source": {
"id": "TWFoaSBCYXpB",
"name": "Pune, Maharashtra, India",
}
}
]
}
}
我尝试使用查询/术语/前缀/通配符方法进行搜索。我想查找以“Ind*”开头的名称,但作为响应,它返回在字符串中的任何位置匹配的字符串。我想要的结果只以“Ind*”开头,但我应该得到“印度”而不是其他结果。
请建议我如何查询 ES 以获得高于预期的结果。
【问题讨论】:
标签: elasticsearch