elasticsearch 具有优先级的Elasticsearch复杂查询
我有很多基于可获得的折扣和指定优先级的价目表的产品。“价格”零件映射如下所示:
elasticsearch 具有优先级的Elasticsearch复杂查询,
elasticsearch,lucene,e-commerce,
elasticsearch,Lucene,E Commerce,我有很多基于可获得的折扣和指定优先级的价目表的产品。“价格”零件映射如下所示: "price": { "properties": { "USD": { "type": "nested", "properties": { "amount": {
"price": {
"properties": {
"USD": {
"type": "nested",
"properties": {
"amount": {
"type": "float"
},
"discount_id": {
"type": "keyword"
},
"price_list_id": {
"type": "keyword"
},
"priority": {
"type": "short"
}
}
}
}
}
根属性是currency(可能有更多的货币,取决于商店)。
价格的真实例子:
"price": {
"USD": [
{
"amount": 10.0,
"price_list_id": 1,
"discount_id": [
1
],
"priority": 1
},
{
"amount": 143.8,
"price_list_id": 1,
"discount_id": [
20,
22
],
"priority": 2
},
{
"amount": 193.8,
"price_list_id": 1,
"discount_id": null,
"priority": 3
}
]
}
输入为:货币、折扣ID数组、价目表ID数组和价格
我需要根据给定的输入匹配所有价格,通过优先级排序,然后将最高优先级价格(最低数字)与给定金额进行比较。当没有产品价格与给定的折扣id匹配时(不必匹配所有id,一个就足够了),则使用带有nulldiscount\u id
值的价格
我将提供一个例子。客户正在按价格筛选产品。最低金额为100美元,最高金额为150美元。假设价目表是id 1
discount\u id
==null的价格
我希望避免编写脚本,但我自己无法解决这个问题。请提供一个示例,说明您期望的搜索结果是什么?我期望的结果是与给定筛选器匹配的根文档的标识符。这些价格只是众多过滤器中的一部分,但其他过滤器运行良好。此示例只是产品的一个嵌套属性。请提供您期望的搜索结果的示例?我期望的结果是与给定筛选器匹配的根文档的标识符。这些价格只是众多过滤器中的一部分,但其他过滤器运行良好。此示例只是产品的一个嵌套属性。