[size=medium]
[b]1.solr服务[/b]
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
[b]2.solr_timing web project 定时器,定时修改索引[/b]
a).service.properties
提供了solr服务的访问路径,数据库连接信息,定时任务时间
b).indextime.xml
提供了更新索引的时间参数,每次新建之后会对其进行修改
[b]3.solr_create_index_version.jar solr_client_index_version.jar[/b]
分别为创建索引需要引入的架包 和 搜索时生成json或xml格式数据的架包
[b]4.solr_home solr配置文件[/b]
solr_home添加到服务器中,为solr服务指定路径,修改说明:
a).solrconfig.xml
创建索引文件放入的路径 <dataDir>${solr.data.dir:D:\solr_home\solr\data}</dataDir>
配置排序字段说明 p805-p815
<requestHandler name="/browse" class="solr.SearchHandler">
<lst name="defaults">
<str name="defType">edismax</str>
<str name="pf">
game_name game_tag
</str>
<str name="qf">
game_name^1 game_tag^0.8
</str>
</lst>
</requestHandler>
b).schema.xml
a.配置分词器 IKAnalyzer(中文分词时需要添加)
p69-p82
<!-- IKAnalyzer field types add by hw 2013-11-19 -->
<fieldType name="text_cn" class="solr.TextField">
<analyzer type="index">
<tokenizer class="org.wltea.analyzer.solr.IKTokenizerFactory" isMaxWordLength="false"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="org.wltea.analyzer.solr.IKTokenizerFactory" isMaxWordLength="true"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
b.配置需要建立索引的字段
p514-p534
<!-- add by hw 2014-1-5 -->
<field name="game_code" type="text_cn" indexed="true" stored="true"/>
<field name="game_ver" type="text_cn" indexed="true" stored="true" />
<field name="game_ver_int" type="int" indexed="true" stored="true" />
<field name="game_type" type="int" indexed="true" stored="true" />
<field name="game_key" type="text_cn" indexed="true" stored="true" />
<field name="game_pkg_name" type="text_cn" indexed="true" stored="true" />
<field name="game_activity" type="text_cn" indexed="true" stored="true" />
<field name="game_size_show" type="text_cn" indexed="true" stored="true" />
<field name="game_size" type="long" indexed="true" stored="true" />
<field name="game_name" type="text_cn" indexed="true" stored="true" />
<field name="game_desc" type="text_cn" indexed="true" stored="true" />
<field name="game_download_url" type="text_cn" indexed="true" stored="true" />
<field name="game_icon_small" type="text_cn" indexed="true" stored="true" />
<field name="game_icon_big" type="text_cn" indexed="true" stored="true" />
<field name="game_android_ver" type="text_cn" indexed="true" stored="true" />
<field name="game_tag" type="text_cn" indexed="true" stored="true"/>
<field name="game_users" type="long" indexed="true" stored="true" />
<field name="game_download_count" type="long" indexed="true" stored="true" />
<field name="modify_time" type="date" indexed="true" stored="true" />
<field name="game_all" type="text_cn" indexed="true" stored="false" multiValued="true" omitNorms="true"/>
注:英文分词时type="text_general" ,中文分词type="text_cn"
c.配置联合查询字段
p653-p655
<!-- add by hw 2014-1-5-->
<copyField source="game_name" dest="game_all"/>
<copyField source="game_tag" dest="game_all"/>
d.配置检索索引条件默认字段 <defaultSearchField>game_all</defaultSearchField>
[/size]
如果需要接入solr服务,我这边有完整的代码,可以留言,尽快回复QQ:806316225
[b]1.solr服务[/b]
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
[b]2.solr_timing web project 定时器,定时修改索引[/b]
a).service.properties
提供了solr服务的访问路径,数据库连接信息,定时任务时间
b).indextime.xml
提供了更新索引的时间参数,每次新建之后会对其进行修改
[b]3.solr_create_index_version.jar solr_client_index_version.jar[/b]
分别为创建索引需要引入的架包 和 搜索时生成json或xml格式数据的架包
[b]4.solr_home solr配置文件[/b]
solr_home添加到服务器中,为solr服务指定路径,修改说明:
a).solrconfig.xml
创建索引文件放入的路径 <dataDir>${solr.data.dir:D:\solr_home\solr\data}</dataDir>
配置排序字段说明 p805-p815
<requestHandler name="/browse" class="solr.SearchHandler">
<lst name="defaults">
<str name="defType">edismax</str>
<str name="pf">
game_name game_tag
</str>
<str name="qf">
game_name^1 game_tag^0.8
</str>
</lst>
</requestHandler>
b).schema.xml
a.配置分词器 IKAnalyzer(中文分词时需要添加)
p69-p82
<!-- IKAnalyzer field types add by hw 2013-11-19 -->
<fieldType name="text_cn" class="solr.TextField">
<analyzer type="index">
<tokenizer class="org.wltea.analyzer.solr.IKTokenizerFactory" isMaxWordLength="false"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="org.wltea.analyzer.solr.IKTokenizerFactory" isMaxWordLength="true"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
b.配置需要建立索引的字段
p514-p534
<!-- add by hw 2014-1-5 -->
<field name="game_code" type="text_cn" indexed="true" stored="true"/>
<field name="game_ver" type="text_cn" indexed="true" stored="true" />
<field name="game_ver_int" type="int" indexed="true" stored="true" />
<field name="game_type" type="int" indexed="true" stored="true" />
<field name="game_key" type="text_cn" indexed="true" stored="true" />
<field name="game_pkg_name" type="text_cn" indexed="true" stored="true" />
<field name="game_activity" type="text_cn" indexed="true" stored="true" />
<field name="game_size_show" type="text_cn" indexed="true" stored="true" />
<field name="game_size" type="long" indexed="true" stored="true" />
<field name="game_name" type="text_cn" indexed="true" stored="true" />
<field name="game_desc" type="text_cn" indexed="true" stored="true" />
<field name="game_download_url" type="text_cn" indexed="true" stored="true" />
<field name="game_icon_small" type="text_cn" indexed="true" stored="true" />
<field name="game_icon_big" type="text_cn" indexed="true" stored="true" />
<field name="game_android_ver" type="text_cn" indexed="true" stored="true" />
<field name="game_tag" type="text_cn" indexed="true" stored="true"/>
<field name="game_users" type="long" indexed="true" stored="true" />
<field name="game_download_count" type="long" indexed="true" stored="true" />
<field name="modify_time" type="date" indexed="true" stored="true" />
<field name="game_all" type="text_cn" indexed="true" stored="false" multiValued="true" omitNorms="true"/>
注:英文分词时type="text_general" ,中文分词type="text_cn"
c.配置联合查询字段
p653-p655
<!-- add by hw 2014-1-5-->
<copyField source="game_name" dest="game_all"/>
<copyField source="game_tag" dest="game_all"/>
d.配置检索索引条件默认字段 <defaultSearchField>game_all</defaultSearchField>
[/size]
如果需要接入solr服务,我这边有完整的代码,可以留言,尽快回复QQ:806316225