-2

我想将以下 SQL 查询转换为 Elasticsearch 搜索查询。谁能帮我解决这个问题,谢谢。

Select sum(total_apples_count) 
from basket where ( apple_color in (
    select apple_color from apple_details where type = "O") || 
    apple_texture in (
        select apple_texture from apple_details where type = "O"
    ) 
);
4

1 回答 1

0

:如果您正在使用,您可以简单地附加using IN

apple_color :()

这个SO可能会帮助你。

为了SUM在您的 ES 查询中使用,您可以在请求正文中执行以下操作:

"aggs":{  
          "total":{  
              "sum":{  
                  "script":"doc['total_apples_count'].value"
               }
           }
       }

参考聚合sum

于 2016-12-06T14:51:57.780 回答