Solr installation and deployment
- Download the Solr installation package and unzip it
- Create Solr home directory
E:\solr\solrHome
D:\software\solr-x.x.x\example\solr
Copy all filesE:\solr\solrHome
under to- Copy the
D:\software\solr-x.x.x
nextcontrib 和 dist
to theE:\solr\
next, the same level as solrHome Revise
E:\solr\solrHome\collection1\conf\solrconfig.xml
<!-- 调整引用的 jar 文件的路径,这里仅给出了一对修改的样例,所有类似这样的都需要修改 引用的 jar 文件在 solrHome 同级的 contrib 和 dist 目录下 solr.install.dir:表示 collection1 所在的目录 solrHome --> <!-- 原内容: --> <lib dir="${solr.install.dir:../../../}/contrib/extraction/lib" regex=".*\.jar" /> <lib dir="${solr.install.dir:../../../}/dist/" regex="solr-cell-\d.*\.jar" /> <!-- 修改后: --> <lib dir="${solr.install.dir:../}/contrib/extraction/lib" regex=".*\.jar" /> <lib dir="${solr.install.dir:../}/dist/" regex="solr-cell-\d.*\.jar" /> <!-- 配置查询时返回的数据格式 --> <requestHandler name="/select" class="solr.SearchHandler"> <lst name="defaults"> <str name="echoParams">explicit</str> <int name="rows">10</int><!--显示数量--> <str name="wt">json</str><!--显示格式--> <str name="df">text</str><!--默认搜索字段--> </lst> </requestHandler>
Copy
D:\software\solr-x.x.x\dist
the solr.war below to the webapps of tomcat, change its name to solr.war, and start tomcat- Copy
D:\software\solr-x.x.x\example\lib\ext
all the jar files under tomcatwebapps\solr\WEB-INF\lib
Revise
webapps\solr\WEB-INF\web.xml
<!-- 放开这段代码,修改 env-entry-value,如下 --> <env-entry> <env-entry-name>solr/home</env-entry-name> <env-entry-value>e:\solr\solrHome</env-entry-value> <env-entry-type>java.lang.String</env-entry-type> </env-entry>
will be
D:\software\solr-x.x.x\example\resources\log4j.properties
copied towebapps\solr\WEB-INF\classes
- Restart tomcat, access
http://localhost:8080/solr
Configure IK Chinese tokenizer
- Download IK Chinese Tokenizer
- Copy the jar file to
E:\solr\contrib\IKAnalyzer\lib
, IKAnalyzer and lib folders need to be created - Copy the jar file to tomcat
webapps\solr\WEB-INF\lib
- Revise
E:\solr\solrHome\collection1\conf\solrconfig.xml
- will be
IKAnalyzer.cfg.xml、ext_stopword.dic、mydict.dic
copied to tomcatwebapps\solr\WEB-INF\classes
Revise
E:\solr\solrHome\collection1\conf\schema.xml
<!-- IKAnalyzer--> <fieldType name="text_ik" class="solr.TextField"> <analyzer type="index" isMaxWordLength="false" class="org.wltea.analyzer.lucene.IKAnalyzer"/> <analyzer type="query" isMaxWordLength="true" class="org.wltea.analyzer.lucene.IKAnalyzer"/> </fieldType>
Custom fieldType and field
Take product information as an example:
Modify the schema.xml file
<!-- 定义分词时使用的类型,这里是 IK 分词器提供的类型 -->
<fieldType name="text_ik" class="solr.TextField">
<analyzer type="index" isMaxWordLength="false" class="org.wltea.analyzer.lucene.IKAnalyzer"/>
<analyzer type="query" isMaxWordLength="true" class="org.wltea.analyzer.lucene.IKAnalyzer"/>
</fieldType>
<!-- 定义域,注意 type,如果属性需要分词的话,type 使用上面定义的 fieldType -->
<field name="goods_name" type="text_ik" indexed="true" stored="true"/>
<field name="goods_category_id" type="string" indexed="true" stored="true"/>
<field name="goods_category_name" type="text_ik" indexed="true" stored="true"/>
<field name="goods_price" type="float" indexed="true" stored="true"/>
<field name="goods_description" type="text_ik" indexed="true" stored="false"/>
<field name="goods_picture" type="string" indexed="false" stored="true"/>
<!-- 定义关键词搜索域 -->
<field name="goods_keywords" type="text_ik" indexed="true" stored="false" multiValued="true"/>
<!-- 定义关键词搜索域要搜索的范围,例如这里的范围是 goods_name 和 goods_description-->
<copyField source="goods_name" dest="goods_keywords"/>
<copyField source="goods_description" dest="goods_keywords"/>
Solr decompressed files and explanations
bin:可执行程序、脚本
contrib:存放了一些扩展的包,用于索引和搜索
dist:其中有一个solr-4.10.3.war 将其部署到tomcat容器中,运行solr
docs:使用说明文档
example:存储了很多solr开发使用的例子工程及目录结构等。
example/solr:
该目录是一个包含了默认配置信息的Solr的Core目录。
example/multicore:
该目录包含了在Solr的multicore中设置的多个Core目录。
example/webapps:
该目录中包括一个solr.war,该war可作为solr的运行实例工程。
licenses:solr相关的一些许可信息
licenses:许可