elasticsearch多次聚合-创新互联
curl -XGET 'http://localhost:9200/alias-*/*/_search?pretty' -d '{
成都创新互联公司坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都做网站、成都网站设计、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的北安网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!"size" : 0,
"query" : {
"function_score" : {
"query" : {
"filtered" : {
"filter" : {
"bool" : {
"should" : [ {
"match" : {
"_all" : {
"query" : "电子",
"type" : "boolean",
"operator" : "AND"
}
}
}, {
"match" : {
"company_name" : {
"query" : "电子",
"type" : "boolean",
"operator" : "AND"
}
}
}, {
"match" : {
"title" : {
"query" : "电子",
"type" : "boolean",
"operator" : "AND"
}
}
} ],
"minimum_should_match" : "1"
}
}
}
},
"functions" : [ {
"filter" : {
"match" : {
"_all" : {
"query" : "电子",
"type" : "boolean",
"operator" : "AND"
}
}
},
"weight" : 2.0
}, {
"filter" : {
"match" : {
"company_name" : {
"query" : "电子",
"type" : "boolean",
"operator" : "AND"
}
}
},
"weight" : 8.0
}, {
"filter" : {
"match" : {
"title" : {
"query" : "电子",
"type" : "boolean",
"operator" : "AND"
}
}
},
"weight" : 4.0
}, {
"filter" : {
"range" : {
"seling_auction_cnt" : {
"from" : 0,
"to" : null,
"include_lower" : false,
"include_upper" : true
}
}
},
"weight" : 1.0
}, {
"field_value_factor" : {
"field" : "company_score",
"factor" : 1.0E-6
}
} ],
"score_mode" : "sum"
}
},
"aggs" : {
"agg" : {
"terms" : {
"field" : "member_id",
"size" : 0,
"order" : {
"top_hit" : "desc"
}
},
"aggregations" : {
"top_hit" : {
"max" : {
"script" : {
"inline" : "_score"
}
}
}
}
},
"agg1" : {
"scripted_metric": {
"init_script": "_agg[\"prd\"] = []",
"map_script": "if(doc[\"cat2_id\"].value) {_agg.prd.add(doc[\"cat2_id\"].value.toString())}",
"combine_script": "combined = [:]; for (tmp in _agg.prd) { if(!combined[tmp]) { combined[tmp] = 1 } }; return combined",
"reduce_script": "reduced = []; for (a in _aggs) { for (entry in a) { reduced.add(entry.key); } }; return reduced"
}
},
"agg2" : {
"scripted_metric": {
"init_script": "_agg[\"prd\"] = []",
"map_script": "if(doc[\"cat2_id\"].value) {_agg.prd.add(doc[\"cat2_id\"].value.toString())}",
"combine_script": "combined = [:]; for (tmp in _agg.prd) { if(!combined[tmp]) { combined[tmp] = 1 } }; return combined",
"reduce_script": "reduced = [:]; for (a in _aggs) { for (entry in a) { word = entry.key; if (!reduced[word] ) { reduced[word] = entry.value; } } }; return reduced"
}
}
}
}'
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
名称栏目:elasticsearch多次聚合-创新互联
链接URL:http://cdiso.cn/article/cspjgi.html