现在的位置: 首页 > 综合 > 正文

solr dataimport 的配置

2013年12月14日 ⁄ 综合 ⁄ 共 2274字 ⁄ 字号 评论关闭

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

 

 

 

 

 

抱歉!评论已关闭.