弹性搜索查询按通配符过滤出ID [英] elastic search query filter out ids by wildcard

查看:104
本文介绍了弹性搜索查询按通配符过滤出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?

推荐答案

是的,可以使用

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆