我想应用下面的示例 elasticsearch 数据 wildcard在 _id
上说 *.000ANT.*
以获取其 _id
包含 000ANT
的所有文档。请帮忙。
"hits": [
{
"_index": "data_collector",
"_type": "agents",
"_id": "Org000LAN_example1.com",
"_score": 1,
"fields": {
"host": [
"example1.com"
]
}
},
{
"_index": "data_collector",
"_type": "agents",
"_id": "000BAN_example2.com",
"_score": 1,
"fields": {
"host": [
"example2.com"
]
}
},
{
"_index": "data_collector",
"_type": "agents",
"_id": "000ANT_example3.com",
"_score": 1,
"fields": {
"host": [
"example3.com"
]
}
}
]
最佳答案
这只是 Andrei Stefan 的 answer 的扩展
{
"query": {
"script": {
"script": "doc['_id'][0].indexOf('000ANT') > -1"
}
}
}
注意:我不知道这种查询对性能的影响,这很可能是个坏主意。谨慎使用并尽可能避免使用。
关于elasticsearch - 如何在 elasticsearch 中对 _id 进行通配符或正则表达式匹配?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30844122/