0

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

Amar Gohil
  • 163
  • 2
  • 12

1 Answers1

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

Please refer to ES range query

Zhitao Yue
  • 219
  • 1
  • 7
  • Hi true, but Bool Must Range not work with list of object – Amar Gohil Jul 31 '17 at 09:09
  • @Amar Gohil It should work. Could you provide your mappings? – Zhitao Yue Jul 31 '17 at 09:28
  • @Zhitoa Yue here it is.... "isOnLineShodAdded" :{"type" : "boolean"}, "productList" : { "properties" : { "grossAmt" : {"type" : "float"}, "netAmt" : {"type" : "float"}, "prodSize" :{ "type": "nested" } } } – Amar Gohil Jul 31 '17 at 09:35
  • I just saw your sample data like this `"productList" : { "properties" : { "prodId" : "2", "netAmt" : 50, "prodSize" :["XS","XL"] } }` Could you change it to `"productList" : { "prodId" : "2", "netAmt" : 50, "prodSize" :["XS","XL"] }` You don't need add `properties` when putting data – Zhitao Yue Jul 31 '17 at 09:44
  • i cant added data without properties give me Error like this object mapping for [productList.prodSize] tried to parse field [null] as object, but found a concrete value – Amar Gohil Jul 31 '17 at 09:49