solr4.4 索引mysql数据库数据

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、添加data-config.xml 或者复制E:\solr-4.4.0\example\example-DIH\solr\db\conf\db-data-config.xml到solr.home目录下,并修改为data-config.xml

修改里面代码

<?xml version="1.0" encoding="utf-8"?>  
<dataConfig>
 <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver"  
   url="jdbc:mysql://localhost:3306/secd"  
   user="root"  
   password=""/>
   <document name="cms">
      <entity name="view_blog" pk="pk_id" query="select a.id as id,a.project_name as title,a.construct as content from pr_project_info a">  
          <field column="id" name="id" />  
          <field column="title" name="title" />  
          <field column="content" name="content" />
      </entity>
 </document> 
</dataConfig>
3、复制E:\solr-4.4.0\dist\solr-dataimporthandler-4.4.0.jar和E:\solr-4.4.0\dist\solr-dataimporthandler-extras-4.4.0.jar到E:\tomcat\webapps\solr\WEB-INF\lib下

4、打开http://localhost:8080/solr/#/collection1,选择dataimport


你可能感兴趣的:(solr4.4 索引mysql数据库数据)