solr dataimport 的配置

1)在solrconfig.xml增加

 <!--新增加的配置-->
   <requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
    <lst name="defaults">


      <str name="config">data-config.xml</str>
   
    </lst>
  </requestHandler>

2)然后在solrconfig.xml同一个目录下,即是solr home目录下增加 data-config.xml 文件

 

<dataConfig>
    <dataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/test" user="root" password="123456"/>
    <document name="movieDoc">
        <entity name="movie" transformer="RegexTransformer,DataToIntTransformer" query="select * from movie" >
       
            <field column="actors" splitBy="," sourceColName="actors"/>
            <field column="director" splitBy="," sourceColName="director"/>
        
            <entity name="type" query="select id as tid from movie_type where mid='${movie.mid}'">
                <field name="tid" column="tid" />
            </entity>
             <entity name="language" query="select id as lid from movie_language where mid='${movie.mid}'">
                <field name="lid" column="lid" />
            </entity>
             <entity name="zone" query="select id as zid from movie_zone where mid='${movie.mid}'">
                <field name="zid" column="zid" />
            </entity>
           
             <entity name="detail" query="select sub_index,title,vid  from movie_detail where mid='${movie.mid}' and chk_yn='y'">
                <field name="sub_index" column="sub_index" />
                <field name="title" column="title" />
                <field name="vid" column="vid" />
            </entity>
            <!--
            <entity name="item_category" query="select CATEGORY_ID from item_category where item_id='${item.ID}'">
                <entity name="category" query="select description from category where id = '${item_category.CATEGORY_ID}'">
                    <field column="description" name="cat" />
                </entity>
            </entity>
            -->
       
        </entity>
    </document>
</dataConfig>

3)加入相关的jar包,apache-solr-dataimporthandler-1.4.0.jar,apache-solr-dataimporthandler-extras-1.4.0.jar,mysql-connector-java-5.1.10.jar

 

启动tomcat,访问http://localhost:8080/solr/dataimport?command=full-import 将数据全部导入solr服务器进行索引

访问http://localhost:8080/solr/dataimport?command=status可以查看运行状态

当修改data-config.xml 文件配置时运行http://localhost:8080/solr/dataimport?command=reload-config可以进行重新加载配置文件

如果想终止运行http://localhost:8080/solr/dataimport?command=abort

 

 

 

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值