SolrCloud数据导入

  • 拷贝/app/solrhome/configsets/basic_configs文件到/app/solrhome,重命名为address
  • 修改solrconfig.xml文件
    在文件最后节点加上
<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
    <lst name="defaults">
       <str name="config">data-config.xmlstr>
    lst>
requestHandler>
  • 在managed-schema里加上字段
"ADDRESSID" type="string" indexed="true" stored="true" required="true" multiValued="false" />
"MEMBERID" type="string" indexed="true" stored="true" required="false" multiValued="false"/>
"MEMBERTYPE" type="string" indexed="true" stored="true" required="false" multiValued="false"/>
"COUNTRY" type="string" indexed="true" stored="true" required="false" multiValued="false"/>
  • 新增data-config.xml文件
<dataConfig>
    <dataSource name="address_01" type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://10.202.38.15:3306/member1?useUnicode=true&serverTimezone=GMT&characterEncoding=UTF-8&userSSL=false" user="member" password="sf123456" batchSize="-1"/>
    <document>
        <entity name="address_01" dataSource="address_01"  pk="ADDRESSID" 
        query="select * ,CONCAT(LONGITUDE,' ',LATITUDE) as job_coordinate from cx_customer_address" 
        deltaQuery="select ADDRESSID  from cx_customer_address where MODIFYTIME > '${dih.last_index_time}'" 
        deltaImportQuery="select * ,CONCAT(LONGITUDE,' ',LATITUDE) as job_coordinate from cx_customer_address where ADDRESSID='${dih.delta.ADDRESSID}'">
            <field column="ADDRESSID" name="ADDRESSID"/>
            <field column="MEMBERID" name="MEMBERID"/>
            <field column="MEMBERTYPE" name="MEMBERTYPE"/>
            <field column="COUNTRY" name="COUNTRY"/>
        entity>
    document>
dataConfig>

你可能感兴趣的:(solrcloud)