首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

Solr试工小记

2012-07-15 
Solr试用小记1、下载tomcat7、solr 3.5.0 以及IKAnalyzer2012_u4,tomcat解压缩2、展开solr压缩包,把包里的exa

Solr试用小记
1、下载tomcat7、solr 3.5.0 以及IKAnalyzer2012_u4,tomcat解压缩

2、展开solr压缩包,把包里的example\solr目录复制到D:\apache-tomcat-7.0.27(tomcat解压缩目录),把example\webapps目录的solr.war复制到D:\apache-tomcat-7.0.27\webapps,把solr包中,dist目录复制到D:\apache-tomcat-7.0.27\solr\dist

3、添加配置文件
  1)D:\apache-tomcat-7.0.27\conf\Catalina\localhost\solr.xml
  

   <?xml version="1.0" encoding="UTF-8"?>    <Context docBase="D:/apache-tomcat-7.0.27/webapps/solr" debug="0" crossContext="true" >     <Environment name="solr/home" type="java.lang.String" value="D:/apache-tomcat-7.0.27/solr" override="true" />    </Context>     


  2) 修改D:\apache-tomcat-7.0.27\conf\server.xml
  
   <Connector port="8080" protocol="HTTP/1.1"               connectionTimeout="20000"               redirectPort="8443" URIEncoding="UTF-8"/>   

4、启动tomcat即可以测试,但是此时还不能进行中文分词,需要将IK的包复制到
   D:\apache-tomcat-7.0.27\webapps\solr\WEB-INF\lib
  修改D:\apache-tomcat-7.0.27\solr\conf\solrconfig.xml
  内容:
   1)<lib dir="D:/apache-tomcat-7.0.27/solr/dist/" regex="apache-solr-cell-\d.*\.jar" />
  <lib dir="D:/apache-tomcat-7.0.27/solr/dist/" regex="apache-solr-clustering-\d.*\.jar" />
  <lib dir="D:/apache-tomcat-7.0.27/solr/dist/" regex="apache-solr-dataimporthandler-\d.*\.jar" />
  <lib dir="D:/apache-tomcat-7.0.27/solr/dist/" regex="apache-solr-langid-\d.*\.jar" />
  <lib dir="D:/apache-tomcat-7.0.27/solr/dist/" regex="apache-solr-velocity-\d.*\.jar" />
  2)<queryResponseWriter name="velocity" enable="${solr.velocity.enabled:false}"/> 原来是true,修改为false
  3)D:\apache-tomcat-7.0.27\solr\conf\schema.xml中增加
  <fieldType name="text" class="solr.TextField">
       <analyzer class="org.wltea.analyzer.lucene.IKAnalyzer"/>
</fieldType>
这样即可以中文分词
http://localhost:8080/solr/admin/analysis.jsp 即可以测试

热点排行