<!-- 添加dataimporthandler标签 -->
<lib dir="${solr.install.dir:../../../..}/contrib/dataimporthandler/lib" regex=".*\.jar" />
<!-- 添加mysql驱动标签 -->
<lib dir="${solr.install.dir:../../../..}/contrib/db/lib" regex=".*\.jar" />
<!-- 商品名称 -->
<field name="product_name" type="string" indexed="true" stored="true" />
<!-- 商品分类ID -->
<field name="product_catalog" type="string" indexed="true" stored="true"/>
<!-- 商品分类名称 -->
<field name="product_catalog_name" type="string" indexed="true" stored="false"/>
<!-- 商品价格 -->
<field name="product_price" type="float" indexed="true" stored="true"/>
<!-- 商品描述 -->
<field name="product_description" type="string" indexed="true" stored="false"/>
<!-- 商品图片地址 -->
<field name="product_picture" type="string" indexed="true" stored="true"/>
<!-- 目标域 -->
<field name="product_keywords" type="string" indexed="true" stored="true" multiValued="true"/>
<!-- 将商品名称添加到目标域 -->
<copyField source="product_name" dest="product_keywords" />
<!-- 将商品描述添加到目标域 -->
<copyField source="product_description" dest="product_keywords" />
<!-- 配置dataimport的requestHandler -->
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">data-config.xml</str>
</lst>
</requestHandler>
<?xml version="1.0" encoding="UTF-8"?>
<dataConfig>
<dataSource
type="JdbcDataSource"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/suimi"
user="root"
password="qbz"
/>
<!-- 上面的数据库名称和用户名密码根据自己的实际来填写 -->
<document>
<entity name="product" query="SELECT pid,name,catalog_name,catalog,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="catalog" name="product_catalog"/>
<field column="price" name="product_price"/>
<field column="description" name="product_description"/>
<field column="picture" name="product_picture"/>
<!-- field中的column的值必须与数据库中的字段一致;name必须是schema.xml中存在的field字段(除了主键ID外,其他的都是我们刚才创建的) -->
</entity>
</document>
</dataConfig>
<!-- 配置中文分词的FieldType -->
<fieldType name="text_ik" class="solr.TextField" >
<analyzer class="org.wltea.analyzer.lucene.IKAnalyzer"></analyzer>
</fieldType>
<!-- 配置中文分词的Field -->
<field name="content_ik" type="text_ik" indexed="true" stored="true"/>
<!-- 商品名称 -->
<field name="product_name" type="text_ik" indexed="true" stored="true" />
<!-- 商品描述 -->
<field name="product_description" type="text_ik" indexed="true" stored="false"/>
<!-- 目标域 -->
<field name="product_keywords" type="text_ik" indexed="true" stored="true" multiValued="true"/>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>IK Analyzer 扩展配置</comment>
<!--用户可以在这里配置自己的扩展停止词字典-->
<entry key="ext_stopwords">stopword.dic;</entry>
<!--用户可以在这里配置自己的扩展字典 ,多个词典用分号隔开
<entry key="ext_dict">mydict.dic;</entry>
-->
<entry key="ext_dict">moren.dic;qubianzhong.dic;</entry>
</properties>
并可以在apache-tomcat-7.0.73\webapps\solr\WEB-INF\classes下新建自己的扩展词典