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萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章