设为首页 收藏本站
查看: 856|回复: 0

[经验分享] Solr学习总结-附加功能

[复制链接]

尚未签到

发表于 2015-11-12 09:47:52 | 显示全部楼层 |阅读模式
  找到与查询结果相似的文档
  http://localhost:8983/solr/select?q=name:edition&mlt=true&mlt.fl=name&mlt.mintf=1&mlt.mindf=1


  mlt.fl:按照结果文档的哪一个field求相似。


  mlt.mintf:结果文档中的本field的某一个词出现的tf大于此值,才以此词求相似。


  mlt.mindf:通上,不过是df


  自定义的显示结果(非xml)
  首先定义渲染器和名字:<queryResponseWriter name=&quot;velocity&quot; class=&quot;org.apache.solr. request.VelocityResponseWriter&quot;/>其次定义请求的处理器(包括显示的结果,行数,默认的查询域,查询的&#26684;式等等):<requestHandler name=&quot;/browse&quot; class=&quot;solr.SearchHandler&quot;>
<lst name=&quot;defaults&quot;>
<str name=&quot;wt&quot;>velocity</str>
<str name=&quot;v.template&quot;>browse</str>
<str name=&quot;v.layout&quot;>layout</str>
<str name=&quot;title&quot;>Solr cookbook example</str>
<str name=&quot;defType&quot;>dismax</str>
<str name=&quot;q.alt&quot;>*:*</str>
<str name=&quot;rows&quot;>10</str>
<str name=&quot;fl&quot;>*,score</str>
<str name=&quot;qf&quot;>name</str>
</lst>
</requestHandler>对匹配的词高亮显示
  
  http://localhost:8983/solr/select?q=name:book&hl=true


  指定高亮显示的field:http://localhost:8983/solr/select?q=name:book&hl=true&hl.fl=name,description
  指定高亮的标签:http://localhost:8983/solr/select?q=name:book&hl=true&hl.simple.pre=<b>&hl.simple.post=</b>
  高亮长文本并获得好的性能:<field name=&quot;name&quot; type=&quot;text&quot; indexed=&quot;true&quot; stored=&quot;true&quot;
termVectors=&quot;true&quot; termPositions=&quot;true&quot; termOffsets=&quot;true&quot; />http://localhost:8983/solr/select?q=name:book&hl=true&hl.useFastVectorHighlighter=true


  
  对某些field按照函数结果进行排序
  http://localhost:8983/solr/select?q=name:company&sort=dist(2,geoX,geoY,13,13)&#43;asc
  按照发音查询

<field name=&quot;name&quot; type=&quot;phonetic&quot; indexed=&quot;true&quot; stored=&quot;true&quot; />
<fieldtype name=&quot;phonetic&quot; stored=&quot;false&quot; indexed=&quot;true&quot; class=&quot;solr.
TextField&quot; >
<analyzer>
<tokenizer class=&quot;solr.StandardTokenizerFactory&quot;/>
<filter class=&quot;solr.DoubleMetaphoneFilterFactory&quot; inject=&quot;false&quot;/>
</analyzer>
</fieldtype>
  自定义忽略的词语

<field name=&quot;name&quot; type=&quot;text_ignored&quot; indexed=&quot;true&quot; stored=&quot;true&quot; />
<fieldType name=&quot;text_ignored&quot; class=&quot;solr.TextField&quot;
positionIncrementGap=&quot;100&quot;>
<analyzer>
<tokenizer class=&quot;solr.WhitespaceTokenizerFactory&quot;/>
<filter class=&quot;solr.StopFilterFactory&quot; ignoreCase=&quot;true&quot;
words=&quot;ignored.txt&quot; enablePositionIncrements=&quot;true&quot; />
</analyzer>
</fieldType>

  对查询结果计算统计
  http://localhost:8983/solr/select?q=name:book&stats=true&stats.field=price


  返回结果:

<lst name=&quot;stats&quot;>
<lst name=&quot;stats_fields&quot;>
<lst name=&quot;price&quot;>
<double name=&quot;min&quot;>27.77</double>
<double name=&quot;max&quot;>39.99</double>
<double name=&quot;sum&quot;>97.86999999999999</double>
<long name=&quot;count&quot;>3</long>
<long name=&quot;missing&quot;>0</long>
<double name=&quot;sumOfSquares&quot;>3276.9851000000003</double>
<double name=&quot;mean&quot;>32.62333333333333</double>
<double name=&quot;stddev&quot;>6.486118510583508</double>
</lst>
</lst>
</lst>
  检查拼写错误

<searchComponent name=&quot;spellcheck&quot; class=&quot;solr.SpellCheckComponent&quot;>
<lst name=&quot;spellchecker&quot;>
<str name=&quot;name&quot;>default</str>
<str name=&quot;field&quot;>name</str>
<str name=&quot;spellcheckIndexDir&quot;>./spellchecker</str><!-- 目录等同于索引目录-->
<str name=&quot;buildOnCommit&quot;>true</str>
</lst>
</searchComponent>
<requestHandler name=&quot;standard&quot; class=&quot;solr.SearchHandler&quot;
default=&quot;true&quot;>
<arr name=&quot;last-components&quot;>
<str>spellcheck</str>
</arr>
</requestHandler>
  http://localhost:8983/solr/spell?q=name:(other boak)&spellcheck=true&spellcheck.collate=true

<lst name=&quot;spellcheck&quot;>
<lst name=&quot;suggestions&quot;>
<lst name=&quot;othar&quot;>
<int name=&quot;numFound&quot;>1</int>
<int name=&quot;startOffset&quot;>6</int>
<int name=&quot;endOffset&quot;>11</int>
<arr name=&quot;suggestion&quot;>
<str>other</str>
</arr>
</lst>
<lst name=&quot;boak&quot;>
<int name=&quot;numFound&quot;>1</int>
<int name=&quot;startOffset&quot;>12</int>
<int name=&quot;endOffset&quot;>16</int>
<arr name=&quot;suggestion&quot;>
<str>book</str>
</arr>
</lst>
<str name=&quot;collation&quot;>name:(other book)</str>
</lst>
</lst>
  group by功能

http://localhost:8983/solr/select?q=name:company&group=true&group.field=mainOfficeId

每个组允许的最大的文档数目:
  http://localhost:8983/solr/select?q=name:company&group=true&group.field=mainOfficeId&group.limit=4.




  



版权声明:本文为博主原创文章,未经博主允许不得转载。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-138202-1-1.html 上篇帖子: Apache Solr单机环境配置(包括中文分词和Java API的使用) 下篇帖子: Solr5.0说明文档
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表