下載 Apache Solr 1.3 http://apache.etoak.com/lucene/solr/1.3.0/apache-solr-1.3.0.zip ,解壓。
To create a project in Eclipse
File > New > Java Project
In ‘Create Java Project’ dialog:
Select ‘Create Project from existing source’. Select directory where the TOP of the code tree lives. Leave other defaults alone.
Select ‘Finish’
Setup build file as an Eclipse build file
Project > Properties > Builders > New > Ant Builder
On ‘Main’ tab:
* Locate ‘build.xml’
* Set base directory to top of build tree
* For argument, add ‘compile’
* Apply
On ‘Targets’ tab:
* Manual build ‘compilel’
* Automatic build ‘compile’
solr 安裝到 tomcat。修改 E:\apache-tomcat-6.0.18\conf\server.xml,加個(gè) URIEncoding="UTF-8",把 8080 的那一塊改為:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8"/>
把下面的內(nèi)容保存到 E:\apache-tomcat-6.0.18\conf\Catalina\localhost\solr.xml,沒(méi)有這個(gè)目錄自行創(chuàng)建。
<Context docBase="E:/apache-solr-1.3.0/dist/apache-solr-1.3.0.war" reloadable="true" >
<Environment name="solr/home" type="java.lang.String" value="E:/apache-solr-1.3.0/example/solr" override="true" />
</Context>
提交數(shù)據(jù)做索引,到 E:\apache-solr-1.3.0\example\exampledocs,運(yùn)行:
E:\apache-solr-1.3.0\example\exampledocs>java -Durl=http://localhost:8080/solr/update -Dcommit=yes -jar post.jar demo-doc*.xml
SimplePostTool: version 1.2
SimplePostTool: WARNING: Make sure your XML documents are encoded in UTF-8, other encodings are not currently supported
SimplePostTool: POSTing files to http://localhost:8080/solr/update..
SimplePostTool: POSTing file demo-doc1.xml
SimplePostTool: POSTing file demo-doc2.xml
SimplePostTool: COMMITting Solr index changes..
運(yùn)行: http://localhost:8080/solr/select/?q=*%3A*&version=2.2&start=0&rows=10&indent=on