本文介绍了如何在Elasticsearch中基于或条件有多个正则表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从id中获取所有 000ANT
和 0BBNTA
,是否与,它可以与regexp一起使用,或者还有其他功能办法?否则,我将不得不针对每个项目(例如000ANT和0BBNTA)查询elasticsearch。请帮忙。
I want to get all 000ANT
and 0BBNTA
from id, is there something similar to terms which works with regexp or is there any other way? Otherwise I will have to query elasticsearch for each item say 000ANT and 0BBNTA. Please help.
下面是我尝试的1,即 000ANT
,但我也想拥有或正则表达式也可以匹配 0BBNTA
的条件。
Below is something that I am trying out for 1 i.e., 000ANT
but I also want to have a or condition so regex can also match 0BBNTA
.
GET dc/ma/_search
{
"fields": [
"host"
],
"filter": {
"bool": {
"must": [
{
"regexp": {
"_uid": {
"value": ".*000ANT.*"
}
}
}
]
}
}
}
推荐答案
使用应该
代替必须
:
{
"fields": [
"host"
],
"filter": {
"bool": {
"should": [
{
"regexp": {
"_uid": {
"value": ".*000ANT.*"
}
}
},
{
"regexp": {
"_uid": {
"value": ".*0BBNTA.*"
}
}
}
]
}
}
}
这篇关于如何在Elasticsearch中基于或条件有多个正则表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!