简体   繁体   中英

Combining missing term filter and range check in elastic search

I get zero result when combining range filter and missing filter together in a query. Query is given below. I get this issue only while combining missing and range individually both works good. Any help is appreciated on correcting the query or the code. I am elastic search 1.7.3 version.

 {
  "query": {
    "filtered": {
      "query": {
        "match_all": {}
      },
      "filter": {
        "bool": {
          "must": [
            {
              "bool": {
                "should": {
                  "missing": {
                    "field": "OrderData.XXXX.XXXXQueue"
                  }
                }
              }
            },
            {
              "range": {
                "OrderData.XXXX.priority": {
                  "from": 1,
                  "to": 5,
                  "include_lower": true,
                  "include_upper": true
                }
              }
            }
          ]
        }
      }
    }
  }
}

Does this Query get you the expected results?

 {
      "query": {
        "filtered": {
          "query": {
            "match_all": {}
          },
          "filter": {
            "bool": {
              "must": {
                "bool": {
                  "should": [{
                    "missing": {
                      "field": "OrderData.XXXX.XXXXQueue"
                    }
                  }, {
                    "range": {
                      "OrderData.XXXX.priority": {
                        "from": 1,
                        "to": 5,
                        "include_lower": true,
                        "include_upper": true
                      }
                    }
                  }]
                }
              }
            }
          }
        }
      }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM