Index a DB table directly into Solr

来源:互联网 发布:无线淘宝收藏链接 编辑:程序博客网 时间:2024/06/08 06:11
1. Start solr   java -jar start.jar2. Edit your solrconfig.xml to add the request handler<requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler"><lst name="defaults">  <str name="config">data-config.xml</str></lst></requestHandler>3. Create a data-config.xml file as follows and save it to the conf dir<dataConfig><dataSource type="JdbcDataSource"   driver="com.mysql.jdbc.Driver"  url="jdbc:mysql://localhost:3306/dbname"   user="root"   password="111111"/>  <document><entity name="id" query="select id,name from mytable"></entity>  </document>    </dataConfig>note: need to creat a DB named dbname and also create a table named mytable with property id and name.add some data in the table. like "1 , testuser"4. Put the url in the browser. "http://localhost:8983/solr/dataimport?command=full-import"5. Use slor admin to select import datas. "http://localhost:8983/solr/select/?q=testuser&version=2.2&start=0&rows=10&indent=on"   You can find the result.
 Please click the url http://wiki.apache.org/solr/DIHQuickStart for more information
原创粉丝点击