对象列表上的 Elasticsearch 范围查询
Elasticsearch range query on list of object
这是我的映射
{ "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 MUST RANGE 但它不适用于对象列表
{
"query": {
"bool": {
"must": {
"range": {
"productList.netAmt": {
"gt": 10,
"lt": 60
}
}
}
}
}
}
请参考ESrange query
这是我的映射
{ "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 MUST RANGE 但它不适用于对象列表
{
"query": {
"bool": {
"must": {
"range": {
"productList.netAmt": {
"gt": 10,
"lt": 60
}
}
}
}
}
}
请参考ESrange query