本文介绍了如何在弹性搜索中对_id进行通配符或正则表达式匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从下面的弹性搜索数据示例我想应用说 *。000ANT。*
在 _id
上,以便获取所有文档,其中 _id
包含 000ANT
。请帮助。
From below sample elasticsearch data I want to apply wildcard say *.000ANT.*
on _id
so as to fetch all docs whose _id
contains 000ANT
. Please help.
"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"
]
}
}
]
推荐答案
尝试这个
{
"filter": {
"bool": {
"must": [
{
"regexp": {
"_uid": {
"value": ".*000ANT.*"
}
}
}
]
}
}
}
这篇关于如何在弹性搜索中对_id进行通配符或正则表达式匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!