Skip to content
iamazy edited this page Sep 17, 2019 · 3 revisions

0 group by聚类

select max(age),count(distinct name),max(height) from student group by name,age,height

1 elasticsearch聚类

目前实现的聚类方法有

sum
max
min
cardinality
terms
top_hits

以上聚类方法单独使用为

select * from apple aggregate by terms(productName,10)
select * from apple aggregate by cardinality(productName)
select * from apple aggregate by top_hits(10)

2. elasticsearch多重聚类

elasticsearch-sql 使用>表示sub-aggs,使用,隔开aggs

select * from apple aggregate by terms(productName,10)>(terms(provider,10)),cardinality(provider)
---如果聚类较多请用括号括起来
select * from apple aggregate by terms(productName,10)>(terms(provider,10),cardinality(provider))

3. elasticsearch nested聚类

select * from apple aggregate by [apple,terms(apple.color,2)];
Clone this wiki locally