1,环境必须是tomcat7.0以上,jdk7.0以上,jre7.0以上,且配置好环境变量;
2,example\webapps 下的solr.war;
3,solr home,
在apache-tomcat-7.0.55\conf\Catalina\localhost中
新增solr.xml文件
<Context docBase="apache-tomcat-7.0.55/webapps/solr.war" debug="0" crossContext="true" >
<Environment name="solr/home" type="java.lang.String" value="D:/solr/solr" override="true" />
</Context>
4,拷贝example\lib\ext下的所有jar 到tomcat_home\webapps\solr\WEB-INF\lib下;
5,tomcat_home\webapps\solr\WEB-INF下新建一个classes文件夹,将example\resources下的log4j.properties拷贝过去;
6.D:/solr/solr,将\example\下的solr拷贝过去;
7.修改collection1\conf中的 solrconfig.xml
将
<!--<lib dir="../../../contrib/extraction/lib" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-cell-\d.*\.jar" />
<lib dir="../../../contrib/clustering/lib/" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-clustering-\d.*\.jar" />
<lib dir="../../../contrib/langid/lib/" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-langid-\d.*\.jar" />
<lib dir="../../../contrib/velocity/lib" regex=".*\.jar" />
<lib dir="../../../dist/" regex="solr-velocity-\d.*\.jar" />-->
。。。。
<!-- A request handler that returns indented JSON by default -->
<requestHandler name="/query" class="solr.SearchHandler">
<bool name="f.title.hl.useFastVectorHighlighter">true</bool>//新增
<lst name="defaults">
。。。。。
//新增
<requestHandler name="/dataimport" class="solr.DataImportHandler">
<lst name="defaults">
<str name="config">db-config.xml</str>
</lst>
</requestHandler>
\collection1\conf\schema.xml的修改
//新定义的参数
<field name="posId" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="posName" type="text_ik" indexed="true" stored="true" required="true" multiValued="false" />
<field name="updateTime" type="date" indexed="true" stored="true" required="true" multiValued="false" />
<field name="text" type="text_ik" indexed="true" stored="false" multiValued="true"/>
//主键
<uniqueKey>posId</uniqueKey>
// 或 与 并<--<solrQueryParser defaultOperator="OR"/> -->
<solrQueryParser defaultOperator="AND"/>
//
<copyField source="posName" dest="text"/>
<fieldType name="text_ik" class="solr.TextField">
<analyzer class="org.wltea.analyzer.lucene.IKAnalyzer"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
</fieldType>
db-config.xml文件
<dataConfig>
<dataSource name="ds" driver="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@192.168.2.1:1515:数据库"
user="user" password="123456" responseBuffering="adaptive" selectMethod="cursor" />
<document>
<entity name="entity-position" dataSource="ds" pk="POS_ID"
query="SELECT V.* FROM POSITION V WHERE V.DELETE_FLAG = 0"
deltaImportQuery="SELECT V.* FROM POSITION V WHERE V.POS_ID = '${dataimporter.delta.POS_ID}'"
deltaQuery="SELECT V.* FROM POSITION V WHERE V.DELETE_FLAG = 0
AND V.UPDATE_TIME > to_date('${dataimporter.last_index_time}','yyyy-mm-dd hh24:mi:ss')"
deletedPkQuery="SELECT V.* FROM POSITION V WHERE V.DELETE_FLAG = 1
AND V.UPDATE_TIME > to_date('${dataimporter.last_index_time}','yyyy-mm-dd hh24:mi:ss')">
<field column="POS_ID" name="posId"/>
<field column="POS_NAME" name="posName"/>
<field column="UPDATE_TIME" name="updateTime"/>
</entity>
</document>
</dataConfig>
dataimport.properties
#Fri Aug 01 17:34:40 CST 2014
last_index_time=2014-08-01 17\:34\:38
entity-position.last_index_time=2014-08-01 17\:34\:38
ik-analyzer-5.01-for solr4.3.jar
放到D:/solr\solr\collection1\lib