弹性搜索查询按通配符过滤出ID [英] elastic search query filter out ids by wildcard
本文介绍了弹性搜索查询按通配符过滤出ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望创建一个查询,该查询将过滤出包含通配符的ID.例如,除了ID包含单词current之外,我想在所有地方搜索内容.这可能吗?
I'm hoping to create a query where it will filter out IDs containing a wildcard. For instance, I would like to search for something everywhere except where the ID contains the word current. Is this possible?
推荐答案
是的,可以使用正则表达式查询.我无法找到使用Complement选项直接执行此操作的方法,因此我暂时使用bool
must_not
来解决您的问题.如有可能,我会稍后进一步完善答案.
Yes it is possible using Regex Filter/Regex Query. I could not figure a way to directly do it using the Complement option hence I've used bool
must_not
to solve your problem for the time being. I'll refine the answer later if possible.
POST <index name>/_search
{
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must_not": [
{
"regexp": {
"ID": {
"value": ".*current.*"
}
}
}
]
}
}
}
这篇关于弹性搜索查询按通配符过滤出ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文