solr 统计频率(term frequency)

  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

 

posted on 2017-12-12 11:22  shaomine  阅读(3060)  评论(0编辑  收藏  举报