1. Start solr java -jar start.jar 2. 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
Index a DB table directly into Solr
最新推荐文章于 2015-03-06 21:12:18 发布