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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM