elasticsearch - Elasticsearch范围查询对象列表

标签 elasticsearch filter range-query

这是我的 map

{             "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" }

                }
            }
        }

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

    }
}
}

我想使用BOOL必须基于产品netAmt搜索数据,
就像netAmt必须在10到60之间
我尝试BOOL必须范围,但它不适用于对象列表
enter image description here

最佳答案

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

请引用ES range query

关于elasticsearch - Elasticsearch范围查询对象列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45411048/

相关文章:

elasticsearch 按字符串字段的长度过滤

elasticsearch - 为什么Elasticsearch服务提供商如此昂贵?

php - 如何在 twig 中显示来自 Unix 时间戳的格式化日期?

java - 带有查询 Dsl 自定义绑定(bind)和/或操作的 Spring 不起作用

elasticsearch - 在 Elasticsearch 的响应字段中格式化日期

algorithm - 如果更新比简单的加法或乘法更复杂,如何应用惰性方法来更新线段树?

elasticsearch - 弹性条款查询电子邮件不起作用

php - 如果查询在引号之间,如何从elasticsearch获取精确的文本匹配

jquery - 在 javascript/php 中移动单引号

elasticsearch - ElasticSearch中的范围查询中 “from”和 “gte”/“gt”是否等效?