Amar Gohil
Amar Gohil

Reputation: 163

Elasticsearch range query on list of object

here my mapping

{             "seoSubscribedFlag": {"type": "boolean"},
            "seoSubscribedExpiryDate": {"type": "date"},
            "userActive" :{"type" : "boolean"},
            "emailVerified" :{"type" : "boolean"},
            "isOnLineShodAdded" :{"type" : "boolean"},
            "productList" : {
                "properties" : {
                    "prodId" : {"type" : "string"},
                    "prodName" : {"type" : "string"},
                    "brand" : {"type" : "string"},
                    "modelNo" : {"type" : "string"},

                    "grossAmt" : {"type" : "float"},
                    "netAmt" : {"type" : "float"},
                    "prodDesc" : {"type" : "string"},
                    "prodKeyFeatures" : {"type" : "string"},
                    "prodSize" :{ "type": "nested" }

                }
            }
        }

here my josn

{
"userId": "2",  
"seoSubscribedFlag": true,
"seoSubscribedExpiryDate": 1501312549,
"userActive" : true,
"emailVerified" : true,
"isOnLineShodAdded" : false,
"productList" : {
    "properties" : {
        "prodId" : "2",            
        "netAmt" : 50,            
        "prodSize" :["XS","XL"]

    }
}
}

i want to search data with BOOL MUST based on product netAmt , Like netAmt Must in between 10 to 60 i try BOOL MUST RANGE but it not work with list of object enter image description here

Upvotes: 0

Views: 1086

Answers (1)

Zhitao Yue
Zhitao Yue

Reputation: 219

{
  "query": {
    "bool": {
      "must": {
        "range": {
          "productList.netAmt": {
            "gt": 10,
            "lt": 60
          }
        }
      }
    }
  }
}

Please refer to ES range query

Upvotes: 2

Related Questions