1.solr服务
a).web.xml配置solr_home的指向
<env-entry>
<env-entry-name>solr/home</env-entry-name>
<env-entry-value>路径</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
b).修改solr日志输出,在solr目录下新建classes文件夹加入log4j.properties
log4j.appender.ROLLING_FILE.File=/var/log/solr.log
2.solr_timingwebproject定时器,定时修改索引
a).service.properties
提供了solr服务的访问路径,数据库连接信息,定时任务时间
b).indextime.xml
提供了更新索引的时间参数,每次新建之后会对其进行修改
3.solr_create_index_version.jarsolr_client_index_version.jar
分别为创建索引需要引入的架包和搜索时生成json或xml格式数据的架包
4.solr_homesolr配置文件
solr_home添加到服务器中,为solr服务指定路径,修改说明:
a).solrconfig.xml
创建索引文件放入的路径<dataDir>${solr.data.dir:D:\solr_home\solr\data}</dataDir>
配置排序字段说明p805-p815
<requestHandlername="/browse"class="solr.SearchHandler">
<lstname="defaults">
<strname="defType">edismax</str>
<strname="pf">
game_namegame_tag
</str>
<strname="qf">
game_name^1game_tag^0.8
</str>
</lst>
</requestHandler>
b).schema.xml
a.配置分词器IKAnalyzer(中文分词时需要添加)
p69-p82
<!--IKAnalyzerfieldtypesaddbyhw2013-11-19-->
<fieldTypename="text_cn"class="solr.TextField">
<analyzertype="index">
<tokenizerclass="org.wltea.analyzer.solr.IKTokenizerFactory"isMaxWordLength="false"/>
<filterclass="solr.StopFilterFactory"ignoreCase="true"words="stopwords.txt"enablePositionIncrements="true"/>
<filterclass="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzertype="query">
<tokenizerclass="org.wltea.analyzer.solr.IKTokenizerFactory"isMaxWordLength="true"/>
<filterclass="solr.StopFilterFactory"ignoreCase="true"words="stopwords.txt"enablePositionIncrements="true"/>
<filterclass="solr.SynonymFilterFactory"synonyms="synonyms.txt"ignoreCase="true"expand="true"/>
<filterclass="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
b.配置需要建立索引的字段
p514-p534
<!--addbyhw2014-1-5-->
<fieldname="game_code"type="text_cn"indexed="true"stored="true"/>
<fieldname="game_ver"type="text_cn"indexed="true"stored="true"/>
<fieldname="game_ver_int"type="int"indexed="true"stored="true"/>
<fieldname="game_type"type="int"indexed="true"stored="true"/>
<fieldname="game_key"type="text_cn"indexed="true"stored="true"/>
<fieldname="game_pkg_name"type="text_cn"indexed="true"stored="true"/>
<fieldname="game_activity"type="text_cn"indexed="true"stored="true"/>
<fieldname="game_size_show"type="text_cn"indexed="true"stored="true"/>
<fieldname="game_size"type="long"indexed="true"stored="true"/>
<fieldname="game_name"type="text_cn"indexed="true"stored="true"/>
<fieldname="game_desc"type="text_cn"indexed="true"stored="true"/>
<fieldname="game_download_url"type="text_cn"indexed="true"stored="true"/>
<fieldname="game_icon_small"type="text_cn"indexed="true"stored="true"/>
<fieldname="game_icon_big"type="text_cn"indexed="true"stored="true"/>
<fieldname="game_android_ver"type="text_cn"indexed="true"stored="true"/>
<fieldname="game_tag"type="text_cn"indexed="true"stored="true"/>
<fieldname="game_users"type="long"indexed="true"stored="true"/>
<fieldname="game_download_count"type="long"indexed="true"stored="true"/>
<fieldname="modify_time"type="date"indexed="true"stored="true"/>
<fieldname="game_all"type="text_cn"indexed="true"stored="false"multiValued="true"omitNorms="true"/>
注:英文分词时type="text_general",中文分词type="text_cn"
c.配置联合查询字段
p653-p655
<!--addbyhw2014-1-5-->
<copyFieldsource="game_name"dest="game_all"/>
<copyFieldsource="game_tag"dest="game_all"/>
d.配置检索索引条件默认字段<defaultSearchField>game_all</defaultSearchField>
如果需要接入solr服务,我这边有完整的代码,可以留言,尽快回复QQ:806316225