03_Solr导入数据库的索引

2018-01-21  本文已影响0人  对方不想理你并向你抛出一个异常

搭建数据库的环境

配置solr

    <!--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"/>
mysql驱动包
    <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/lucene"   
          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>

web界面

上一篇下一篇

猜你喜欢

热点阅读