您好,登錄后才能下訂單哦!
一、配置中文分析器
使用IKAnalyzer
配置方法:
1)把IK的jar包添加到solr工程中/WEB-INF/lib目錄下
2)把IK的配置文件擴(kuò)展詞典,放到classpath下。/WEB-INF/classes目錄下
3)在schema.xml中定義FieldType,指定使用IK作為分析器
<!-- IKAnalyzer--> <fieldType name="text_ik" class="solr.TextField"> <analyzer class="org.wltea.analyzer.lucene.IKAnalyzer"/> </fieldType>
4)重啟tomcat
二、業(yè)務(wù)域的定義
1)創(chuàng)建數(shù)據(jù)庫
需要導(dǎo)入的字段:pid,name,catelog_name,price,description,picture
2)每個(gè)字段需要對(duì)應(yīng)索引庫中的一個(gè)field
一條記錄對(duì)應(yīng)一個(gè)Document,一個(gè)字段對(duì)應(yīng)一個(gè)域
schema.xml中:
<!--product--> <field name="product_name" type="text_ik" indexed="true" stored="true"/> <field name="product_price" type="float" indexed="true" stored="true"/> <field name="product_description" type="text_ik" indexed="true" stored="false" /> <field name="product_picture" type="string" indexed="false" stored="true" /> <field name="product_catalog_name" type="string" indexed="true" stored="true" /> <field name="product_keywords" type="text_ik" indexed="true" stored="false" multiValued="true"/> <copyField source="product_name" dest="product_keywords"/> <copyField source="product_description" dest="product_keywords"/>
三、配置DataImport功能(測(cè)試用)
步驟:
1、把DataImport插件需要的jar包添加到solr中
solr-dataimporthandler-4.10.3.jar
solr-dataimporthandler-extras-4.10.3.jar
可以放到solrhome/Collection1/lib目錄下
2、需要mysql的數(shù)據(jù)庫驅(qū)動(dòng)的jar包
可以放到Collection1/lib目錄下
3、需要在solrconfig.xml添加一個(gè)RequestHandler處理器
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"> <lst name="defaults"> <str name="config">data-config.xml</str> </lst> </requestHandler>
4、在solrconfig.xml配置文件所在的目錄添加一個(gè)data-config.xml文件
配置連接數(shù)據(jù)庫的連接串
查詢數(shù)據(jù)庫的sql語句
結(jié)果集和索引庫的映射關(guān)系
<?xml version="1.0" encoding="UTF-8" ?> <dataConfig> <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/solr" user="root" password="root"/> <document> <entity name="product" query="SELECT pid,name,catalog_name,price,description,picture FROM products "> <field column="pid" name="id"/> <field column="name" name="product_name"/> <field column="catalog_name" name="product_catalog_name"/> <field column="price" name="product_price"/> <field column="description" name="product_description"/> <field column="picture" name="product_picture"/> </entity> </document> </dataConfig>
5、重啟tomcat
以上這篇solr 配置中文分析器/定義業(yè)務(wù)域/配置DataImport功能方法(測(cè)試用)就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持億速云。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。