Solr部署摘要
Solr官网:http://lucene.apache.org/solr/
D:\workspace\apache-tomcat-6.0.35\conf\Catalina\localhost\solr.xml
<Context docBase="D:/workspace/apache-solr-3.3.0/dist/apache-solr-3.3.0.war" debug="0" crossContext="true" > <Environment name="solr/home" type="java.lang.String" value="D:/workspace/projectname/html/solr" override="true" /> </Context>
D:\workspace\projectname\html\solr\npscore\conf\solrconfig.xml追加
<lib dir="D:/workspace/apache-solr-3.3.0/dist" regex="apache-solr-dataimporthandler-\d.*\.jar" /> <lib dir="D:/workspace/apache-solr-3.3.0/dist" regex="ojdbc\d.*\.jar" /> <requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"> <lst name="defaults"> <str name="config">data-config.xml</str> </lst> </requestHandler>
D:\workspace\projectname\html\solr\npscore\conf\data-config.xml
<?xml version="1.0" encoding="UTF-8"?> <dataConfig> <dataSource type="JdbcDataSource" driver="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@localhost:1521:xe" user="******" password="******"/> <document> <entity name="article" query="select * from article"> </entity> </document> </dataConfig>
D:\workspace\apache-solr-3.3.0\dist别忘记将数据库jar扔个这里面
solr索引重建
http://localhost:8983/solr/npscore/dataimport?command=full-import
http://localhost:8983/solr/npscore/dataimport?command=full-import&clean=false
tomcat配置server.xml增加默认监听solr端口8983
<Connector URIEncoding="UTF-8" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" enableLookups="false" maxHttpHeaderSize="8192" maxSpareThreads="75" maxThreads="150" minSpareThreads="25" port="8983" redirectPort="8443"/>