欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Solr部署摘要 博客分类: Java  

程序员文章站 2024-02-04 15:31:10
...
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"/>