Solr学习总结-附加功能

找到与查询结果相似的文档

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="velocity" class="org.apache.solr. request.VelocityResponseWriter"/>
其次定义请求的处理器(包括显示的结果,行数,默认的查询域,查询的格式等等):
<requestHandler name="/browse" class="solr.SearchHandler">
<lst name="defaults">
<str name="wt">velocity</str>
<str name="v.template">browse</str>
<str name="v.layout">layout</str>
<str name="title">Solr cookbook example</str>
<str name="defType">dismax</str>
<str name="q.alt">*:*</str>
<str name="rows">10</str>
<str name="fl">*,score</str>
<str name="qf">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="name" type="text" indexed="true" stored="true"
termVectors="true" termPositions="true" termOffsets="true" />
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)+asc

按照发音查询

<field name="name" type="phonetic" indexed="true" stored="true" />
<fieldtype name="phonetic" stored="false" indexed="true" class="solr.
TextField" >
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.DoubleMetaphoneFilterFactory" inject="false"/>
</analyzer>
</fieldtype>

自定义忽略的词语

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

对查询结果计算统计

http://localhost:8983/solr/select?q=name:book&stats=true&stats.field=price

返回结果:

<lst name="stats">
<lst name="stats_fields">
<lst name="price">
<double name="min">27.77</double>
<double name="max">39.99</double>
<double name="sum">97.86999999999999</double>
<long name="count">3</long>
<long name="missing">0</long>
<double name="sumOfSquares">3276.9851000000003</double>
<double name="mean">32.62333333333333</double>
<double name="stddev">6.486118510583508</double>
</lst>
</lst>
</lst>

检查拼写错误

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
<lst name="spellchecker">
<str name="name">default</str>
<str name="field">name</str>
<str name="spellcheckIndexDir">./spellchecker</str><!-- 目录等同于索引目录-->
<str name="buildOnCommit">true</str>
</lst>
</searchComponent>
<requestHandler name="standard" class="solr.SearchHandler"
default="true">
<arr name="last-components">
<str>spellcheck</str>
</arr>
</requestHandler>

http://localhost:8983/solr/spell?q=name:(other boak)&spellcheck=true&spellcheck.collate=true

<lst name="spellcheck">
<lst name="suggestions">
<lst name="othar">
<int name="numFound">1</int>
<int name="startOffset">6</int>
<int name="endOffset">11</int>
<arr name="suggestion">
<str>other</str>
</arr>
</lst>
<lst name="boak">
<int name="numFound">1</int>
<int name="startOffset">12</int>
<int name="endOffset">16</int>
<arr name="suggestion">
<str>book</str>
</arr>
</lst>
<str name="collation">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.


你可能感兴趣的:(xml,velocity,Solr,Class,文档)