网站展示型和营销型有什么区别,WordPress文章链接重定向,做服装加工哪个网站比较好,吉林省吉林市邮编需求背景#xff1a;
从es查询数据出来的时候#xff0c;要求type为CATALOG的数据排在最前面#xff0c;也就是目录类型的要放在最前面#xff0c;而且要求按照层级排序#xff0c;从L1到L5顺序排序
直接上解法#xff1a;
{//查询条件query: {bool…需求背景
从es查询数据出来的时候要求type为CATALOG的数据排在最前面也就是目录类型的要放在最前面而且要求按照层级排序从L1到L5顺序排序
直接上解法
{//查询条件query: {bool: {//必须满足must: [{term: {status: PUBLISHED}},{bool: {//多条件满足一个即可should: {terms: {subAssetsType: [CATALOG,TABLE,VIEW,DATA_OBJECT,REPORT,FILE]}}}}]}},//返回的条数size:200,//排序条件sort: [{_script: {type: number,script: {lang: painless,//这里主要就是把目标的分数set为大值这里不支持split方法和charAt方法也不支持可以用contains和indexOf方法source: int catalogPriority doc[subAssetsType].value CATALOG ? 1 : 0; int slashCount 0; if (catalogPriority 1 doc.containsKey(catalogPath)) { String catalogPathValue doc[catalogPath].value; if (catalogPathValue ! null !catalogPathValue.isEmpty()) { for (int i 0; i catalogPathValue.length(); i) {if (catalogPathValue.substring(i, i 1).contains(/)) {slashCount;}} } } return catalogPriority * 1000 - slashCount;},//在这里进行倒叙这样目标数据就排到前面了order: desc}},{_score:DESC}],//聚合条件aggs: {subs: {terms: {//聚合的字段类似group by subAssetsTypefield: subAssetsType,order: { // 排序方式_count: asc // 按照计数降序排列},size: 100}}}
}