我有一个这样的json
{"index":{"_index":"companydatabase"}}
{"FirstName":"ELVA","LastName":"RECHKEMMER","Designation":"CEO","Salary":"154000","DateOfJoining":"1993-01-11","Address":"8417 Blue Spring St. Port Orange, FL 32127","Gender":"Female","Age":62,"MaritalStatus":"Unmarried","Interests":["Body Building","Illusion","Protesting","Taxidermy","TV watching","Cartooning","Skateboarding"]}
{"index":{"_index":"companydatabase"}}
{"FirstName":"JENNEFER","LastName":"WENIG","Designation":"President","Salary":"110000","DateOfJoining":"2013-02-07","Address":"16 Manor Station Court Huntsville, AL 35803","Gender":"Female","Age":45,"MaritalStatus":"Unmarried","Interests":["String Figures","Working on cars","Button Collecting","Surf Fishing"]}
{"index":{"_index":"companydatabase"}}
我想统计一下这些人之间最共同的兴趣
我试着这样说:
request_body = {
"size": 0,
"aggs": {
"interests": {
"terms": {
"field": "Interests.keyword",
"size": 10,
"order": {
"count": "desc"
}
}
}
}
}
JSON(es.search(index="companydatabase", body=request_body))
但它不起作用
谢谢你帮我
1条答案
按热度按时间guicsvcw1#
我在你的数据集上试过了,你对这两个例子没有任何共同的兴趣,因此一切都是1,在JSON下面使用,其中一些是共同的兴趣
还有
现在,默认情况下,terms aggs根据doc_count对bucket进行排序,因此查询中不需要其他顺序
下面给你