tomcat下solr初使用-windows

Solr是一个高性能,采用Java5开发,基于Lucene的全文搜索服务器。同时对其进行了扩展,提供了比Lucene更为丰富的查询语言,同时实现了可配置、可扩展并对查询性能进行了优化,并且提供了一个完善的功能管理界面,是一款非常优秀的全文搜索引擎。

1. 复制solr.war到tomcat/webapps下
2. 设置solr HOME
    2.1 复制solr/example/solr到F
    2.2 修改tomcat/bin/catalina.bat 添加:set JAVA_OPTS=%JAVA_OPTS% -Dsolr.solr.home="F:/solr"
    2.3 将solr下的contrib和dist复制到F:/solr/collection1/conf
    2.4 修改F:/solr/collection1/conf/solrconfig.xml【<lib dir="/conf/contrib/extraction/lib" regex=".*\.jar" />】
3. 添加缺失jar,复制solr/example/lib/ext下的jar到tomcat/lib下
4. 添加中文分词
    4.1  复制solr/contrib/analysis-extras/lucene-libs/lucene-analyzers-smartcn-4.7.1.jar到tomcat/webapps/solr/WEB-INF/lib下
    4.2   在F:/solr/collection1/conf/schema.xml中添加类型:
<fieldType name=" SmartChinese" class="solr.TextField" sortMissingLast="true" omitNorms="true">
  <analyzer class="org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer"/>
 </fieldType>
5. 数据类型设置注意: 如果id设置为int,就要修改F:/solr/testCore1/conf/elevate.xml --> id="MA147LL/A"修改成数字

参考:

异常处理:
 1. WARN SolrResourceLoader Can't find (or read) directory to add to classloader: ../../../contrib/extraction/lib (resolved as: /home/solr_home/collection1/../../../contrib/extraction/lib). --> http://my.oschina.net/20130614/blog/145002 

2. Installing Solr on Tomcat on Windows, Error Solr SEVERE: Error filterStart -->   http://www.tuicool.com/articles/INBVRb

3. Caused by: org.apache.solr.common.SolrException: Invalid Number: MA147LL/A  -->  http://itindex.net/detail/47230-solr4.2.1-%E5%8D%87%E7%BA%A7-4.6.0


----------------------------------------------------------------------------------------------------------
查询参数说明:https://cwiki.apache.org/confluence/display/solr/The+Standard+Query+Parser

指定字段搜索并返回指定的字段: http://127.0.0.1:8080/solr/photo/select?q=description:408118&fl=id,description

匹配yc并id在100030-100040之间的:http://127.0.0.1:8080/solr/user/select?q=yc&fq=id:[100030+TO+100040]

join搜索:http://127.0.0.1:8080/solr/photo/select?q={!join+from=id+to=userId+fromIndex=user+v='nickname:2004'}

IN查询:http://127.0.0.1:8080/solr/photo/select?q=userId:(100034+OR+100042) || http://127.0.0.1:8080/solr/photo/select?q=userId:100034+OR+userId:100042

http://127.0.0.1:8080/solr/photo/select?{!join+from=id+to=userId+fromIndex=user}&q=*:*&fq=userId:%28100034%20OR%20100042%20OR%20100135%29&qf=state:%280+OR+1%29&sort=id+desc&start=3&rows=3


----------------------------------------------------------------------------------------------------------
更改solr的打分规则,按权重大小返回
修改solrconfig.xml添加下图红色框内的代码

测试:http://127.0.0.1:8080/solr/photo/select?q=曲阜
第一种配置返回数据如下
第二种配置返回数据如下
可以看出第一种配置address权重值高于description,所以address出现关键字“曲阜”的优先排在前面

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值