1、統計單詞在某個字段出現的頻率次數
term frequency實現使用了function query.
例如統計‘公司’這個關鍵字在text這個字段中出現的次數
在返回的時候進行計算統計,即在返回參數fl中設置為fl=id,freq:termfreq(text,'公司')
http://localhost:8983/solr/test/select?fl=id,freq:termfreq(text,'公司')&indent=on&q=*:*&wt=json
對於多個term的Or查詢,用sum進行統計,termfreq不支持phrase的統計。
freq:sum(termfreq(text,'中國'),termfreq(text,'公司'))
http://localhost:8983/solr/test/select?fl=freq:sum(termfreq(text,'中國'),termfreq(text,'公司'))&indent=on&q=*:*&wt=json