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

发布了118 篇原创文章 · 获赞 47 · 访问量 32万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章