【Solr】solr suggest

[size=large][b]1. Add some testing data to solr[/b][/size]
open command prompt, and cd D:\solr_home\exampledocs

D:\solr_home\exampledocs>java -Durl=http://localhost:8080/solr/update -jar post jar *xml

If you can see the following information, adding index is successfully.

SimplePostTool version 1.5
Posting files to base url [http://localhost:8080/solr/update|http://localhost:8080/solr/update] using content-type
pplication/xml..
POSTing file gb18030-example.xml
POSTing file hd.xml
POSTing file ipod_other.xml
POSTing file ipod_video.xml
POSTing file manufacturers.xml
POSTing file mem.xml
POSTing file money.xml
POSTing file monitor.xml
POSTing file monitor2.xml
POSTing file mp500.xml
POSTing file sd500.xml
POSTing file solr.xml
POSTing file utf8-example.xml
POSTing file vidcard.xml
14 files indexed.
COMMITting Solr index changes to [http://localhost:8080/solr/update|http://localhost:8080/solr/update]..

Here, if use command D:\solr_home\exampledocs>java -jar post jar *xml

will has the error SimplePostTool: FATAL: IOException while posting data: java.net.ConnectException: Connection refused: connect

that's because solr uses default port 8983, here is using port 8080.

[img]http://dl.iteye.com/upload/attachment/0077/2344/7230cbe0-3ab6-32f3-8eb0-674c9efed4eb.png[/img]

[size=large][b]2. modify configuration[/b][/size]
open file D:\solr_home\solr\collection1\conf\solrconfig.xml

add configuration:

<searchComponent name="suggest" class="solr.SpellCheckComponent">
<lst name="spellchecker">
<str name="name">suggest</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookup</str>
<str name="field">name</str>
<float name="threshold">0.005</float>
<str name="buildOnCommit">true</str>
<!--<str name="storeDir">spellchecker</str>-->
</lst>
</searchComponent>

<requestHandler name="/suggest" class="org.apache.solr.handler.component.SearchHandler">
<lst name="defaults">
<str name="spellcheck">true</str>
<str name="spellcheck.dictionary">suggest</str>
<str name="spellcheck.count">10</str>
<str name="spellcheck.onlyMorePopular">true</str>
<str name="spellcheck.collate">true</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>


3. test
In the browser input http://localhost:8983/solr/suggester/?q=s , you will set the following result:

<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">2</int>
</lst>
<lst name="spellcheck">
<lst name="suggestions">
<lst name="s">
<int name="numFound">10</int>
<int name="startOffset">0</int>
<int name="endOffset">1</int>
<arr name="suggestion">
<str>sdram</str>
<str>system</str>
<str>some</str>
<str>server</str>
<str>series</str>
<str>sp2514n</str>
<str>samsung</str>
<str>spinpoint</str>
<str>sata</str>
<str>search</str>
</arr>
</lst>
<str name="collation">sdram</str>
</lst>
</lst>
</response>

interface

[img]http://dl.iteye.com/upload/attachment/0077/2346/2cd80d8d-d46f-3942-a8ca-69c0db13ac70.png[/img]


http://wiki.apache.org/solr/Suggester
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值