Solr服務器配置

1. Solr服務搭建

1.1. Solr的環境

Solrjava開發。

需要安裝jdk

安裝環境Linux

需要安裝Tomcat

1.2. 搭建步驟

第一步:把solr 的壓縮包上傳到Linux系統

第二步:解壓solr

第三步:安裝Tomcat,解壓縮即可。

第四步:把solr部署到Tomcat下。

第五步:解壓縮war包。啓動Tomcat解壓。

第六步:把/root/solr-4.10.3/example/lib/ext目錄下的所有的jar包,添加到solr工程中。

[root@localhost ext]# pwd

/root/solr-4.10.3/example/lib/ext

[root@localhost ext]# cp * /usr/local/solr/tomcat/webapps/solr/WEB-INF/lib/

第七步:創建一個solrhome/example/solr目錄就是一個solrhome。複製此目錄到/usr/local/solr/solrhome

[root@localhost example]# pwd

/root/solr-4.10.3/example

[root@localhost example]# cp -r solr /usr/local/solr/solrhome

[root@localhost example]#

第八步:關聯solrsolrhome。需要修改solr工程的web.xml文件。

第九步:啓動Tomcat

http://192.168.25.154:8080/solr/

windows下的配置完全一樣。

 

 

1.3. 配置業務域

schema.xml中定義

1、商品Id

2、商品標題

3、商品賣點

4、商品價格

5、商品圖片

6、分類名稱

7、商品描述

 

創建對應的業務域。需要制定中文分析器。

 

創建步驟:

第一步:把中文分析器添加到工程中。

1、IKAnalyzer2012FF_u1.jar添加到solr工程的lib目錄下

2、把擴展詞典、配置文件放到solr工程的WEB-INF/classes目錄下。

第二步:配置一個FieldType,制定使用IKAnalyzer

修改schema.xml文件

修改Solrschema.xml文件,添加FieldType

<fieldType name="text_ik" class="solr.TextField">

  <analyzer class="org.wltea.analyzer.lucene.IKAnalyzer"/>

</fieldType>

 

第三步:配置業務域,type制定使用自定義的FieldType

設置業務系統Field

<field name="item_title" type="text_ik" indexed="true" stored="true"/>

<field name="item_sell_point" type="text_ik" indexed="true" stored="true"/>

<field name="item_price"  type="long" indexed="true" stored="true"/>

<field name="item_image" type="string" indexed="false" stored="true" />

<field name="item_category_name" type="string" indexed="true" stored="true" />

<field name="item_desc" type="text_ik" indexed="true" stored="false" />

 

<field name="item_keywords" type="text_ik" indexed="true" stored="false" multiValued="true"/>

<copyField source="item_title" dest="item_keywords"/>

<copyField source="item_sell_point" dest="item_keywords"/>

<copyField source="item_category_name" dest="item_keywords"/>

<copyField source="item_desc" dest="item_keywords"/>

 

第四步:重啓tomcat

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章