solrcloud jsonfacet分組聚合 unique計數不許確

jsonfacet分組聚合查詢算法

unique、hll函數問題json

對不一樣的值進行估算,並不是準確的值,分佈式

優勢:節省內存消耗,用分組算法對不一樣的值count進行估算函數

缺點:沒法準確統計count(distinct key)spa

區別:blog

unique給定字段的唯一值的數量。超過100個值,它不會產生精確的估計,唯一的facet函數是Solr最快速的實現來計算不一樣值的數量內存

hll經過超log-log算法的分佈式基數估計it

記錄:request

json.facet={fz:{type:terms,field:khid,refine:true,overrequest:100000,limit:10,facet:{summy:"sum(my)",sumcnt:"hll(posid)"}}}&fq=month:(201808)語法

json.facet={fz:{type:terms,field:khid,refine:true,overrequest:100000,limit:10,facet:{summy:"sum(my)",sumcnt:"unique(posid)"}}}&fq=month:(201808)

 

 

 

計算出的sumcnt是估算,而不是精確計數

hll函數比unqie函數估算的準確些,但都不精確

解決方法:

一、用stats語法對count(distinct)統計

stats=true&stats.field={!countDistinct=true}posid&fq=month:(201808)

精確統計,對全部節點的數據進行全面統計,耗時高,吃內存

 

 

二、dv函數解決

&indent=on&json.facet={fz:{terms:{field:posid,method:dv,limit:1000000}}}

相關文章
相關標籤/搜索