Elasticsearch进行过滤的时候使用位运算

代码

如果一共有4位,如0000,欲匹配xx11.
1.利用script
eg:只匹配11

{
  "query": {
    "bool": {
      "filter": {
        "script": {
          "script": "(doc['id'].value&3)==3"
        }
      }
    }
  }
}

2.利用should
should精确查找所有组合:0011(3)、0111(7)、1011(11)、1111(15)。

How to make a bitwise comparison with MVEL in Elasticsearch Script Filter
Request to add new Integer Bitwise operator for query DSL
Script query

posted @ 2020-01-14 14:57  thewindkee  阅读(904)  评论(0编辑  收藏  举报