首页 > 其他分享 >ES中reverse_nested+sum+bucket_sort

ES中reverse_nested+sum+bucket_sort

时间:2023-09-05 17:48:25浏览次数:54  
标签:sort gs2Entity reverse agg sum aggregations long nested

记一次嵌套sum聚合的排序DSL

场景:根据nested_gs2Entity.kw_entity聚合,filter对聚合结果过滤类型是产品,实体是需要关心的产品列表,在结果中sum互动量long_interaction,和花费long_paidPrice
然后在结果中根据sum的结果排序
{ "aggregations": { "agg_entity_a": { "aggregations": { "filter_product_agg": { "aggregations": { "agg_entity_b": { "aggregations": { "reverse_nested_agg": { "aggregations": { "sum_long_interaction": { "sum": { "field": "long_interaction" } }, "sum_long_paidPrice": { "sum": { "field": "long_paidPrice" } } }, "reverse_nested": {} }, "bucket_agg_a": { "bucket_sort": { "sort": [ { "reverse_nested_agg>sum_long_interaction": "desc" } ] } } }, "terms": { "field": "nested_gs2Entity.kw_entity", "size": 10 } } }, "filter": { "bool": { "must": [ { "term": { "nested_gs2Entity.kw_type": { "value": "product" } } }, { "terms": { "nested_gs2Entity.kw_entity": [ "欧莱雅男士劲能焕亮青春精华露", "欧莱雅金致臻颜花蜜奢养精华蜜", "欧莱雅金致臻颜牡丹奢养粉妍精华液", "欧莱雅青春密码酵素精华肌底液" ] } } ] } } } }, "nested": { "path": "nested_gs2Entity" } } }

标签:sort,gs2Entity,reverse,agg,sum,aggregations,long,nested
From: https://www.cnblogs.com/joke0406/p/17680316.html

相关文章

  • python内置函数 - map, reduce, filter, sort
    1,map(fn,可迭代对象)参数fn为一个参数的函数lambda方式my_list=[2,3,4,5]result=map(lambdax:x*x,my_list)#返回元素平方值的迭代器print(type(result))#<class'map'>print(isinstance(result,collections.abc.Iterator))#Truenew_list=list(re......
  • 力扣——1 [两数之和](https://leetcode.cn/problems/two-sum/)
    给定一个整数数组nums和一个整数目标值target,请你在该数组中找出和为目标值target的那两个整数,并返回它们的数组下标。你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。你可以按任意顺序返回答案。示例1:输入:nums=[2,7,11,15],tar......
  • [AIGC] a brief summary for this week, replica and localGPT
    Inthisweek,Iexperiencedtwomainprojects,replicaandlocalGPT.replicademo:Replicaistryingtobuildamodelhub.Ihaven'tdiveinitsstructureyet,butIwilldomoreresearchbecauseIbeliveit'llbemorepopularandwidelyused......
  • AGC057E RowCol/ColRow Sort【性质,DP】
    给定一个\(n\timesm\),值域\([0,9]\)的矩阵\(B\),计数有多少个大小相同的矩阵\(A\)满足下列条件:分别对\(A\)的每一列中元素从小到大排序,再分别对\(A\)的每一行中元素从小到大排序能够得到\(B\)。分别对\(A\)的每一行中元素从小到大排序,再分别对\(A\)的每一列中......
  • D. Sorting By Multiplication
    D.SortingByMultiplicationYouaregivenanarray$a$oflength$n$,consistingofpositiveintegers.Youcanperformthefollowingoperationonthisarrayanynumberoftimes(possiblyzero):choosethreeintegers$l$,$r$and$x$suchthat$1\lel......
  • [LeetCode][416]partition-equal-subset-sum
    ContentGivenanintegerarraynums,returntrueifyoucanpartitionthearrayintotwosubsetssuchthatthesumoftheelementsinbothsubsetsisequalorfalseotherwise. Example1:Input:nums=[1,5,11,5]Output:trueExplanation:Thearraycanb......
  • [LeetCode][494]target-sum
    ContentYouaregivenanintegerarraynumsandanintegertarget.Youwanttobuildanexpressionoutofnumsbyaddingoneofthesymbols'+'and'-'beforeeachintegerinnumsandthenconcatenatealltheintegers.Forexample,if......
  • B. Split Sort
    B.SplitSortYouaregivenapermutation$^{\dagger}$$p_1,p_2,\ldots,p_n$ofintegers$1$to$n$.Youcanchangethecurrentpermutationbyapplyingthefollowingoperationseveral(possibly,zero)times:choosesome$x$($2\lex\len$);create......
  • CF1864B Swap and Reverse 题解
    注意到交换操作,无法改变下标的奇偶性,因此只能通过考虑翻转操作改变。注意到如果\(i\)是奇数,那么要令\(i+k-1\)为偶数的话\(k\)必须为偶数,若\(i\)是偶数,要令\(i+k-1\)是奇数的话,\(k\)也应为偶数,而\(k\)为奇数的情况翻转了也无法改变奇偶性。因此通过\(k\)的奇偶性......
  • 2023.08.29T3 - summer - solution
    summerProblemSolution挺好的题,题解也写得很清楚,因此我不过是把题解抄一遍。赛时打了\(40\)分,然后挂了\(20\)分,因为不会前缀和(这个人暴力求区间和,铸币吧)。前\(40\)分就是记忆化搜索+单调栈:首先考察对于一个确定的序列,如何求出一段区间的权值和。那么首先就要知道如......