1: Add the following configuration to tomcat_home/solr/config/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: Create the data-config.xml file in tomcat_home/solr/config/(in the same directory as solrconfig. xml), add the following content
<DataConfig>
<DataSource type = "JdbcDataSource" driver = "Oracle. jdbc. driver. oracleDriver "url =" jdbc: oracle: thin: @ // 192.98.12.216: 1521/db11g "user =" test1 "password =" test1 "/>
<Document>
<Entity name = "id" query = "select OBJECTID, F_PRODUCTNAME, F_DATAFORMATDES from cj_billion">
<Field column = "OBJECTID" name = "id"/>
<Field column = "F_PRODUCTNAME" name = "geo_name"/>
<Field column = "F_DATAFORMATDES" name = "geo_summary"/>
</Entity>
</Document>
</DataConfig>
3: Add the following fields to the tomcat_home/solr/conf/schema. xml file:
<Field name = "geo_name" type = "text_general" indexed = "true" stored = "true"/>
<Field name = "geo_summary" type = "text_general" indexed = "true" stored = "true"/>
4: place the oracle jdbc driver in tomcat_home/webapps/solr/WEB_INF/lib.
5: copy the apache-solr-dataimporthandler-3.6.1.jar and apache-solr-dataimporthandler-extras-3.6.1.jar in the solr_home/dist/folder to the tomcat_home/solr/lib/folder
6: start tomcat and access http: // localhost: 8081/solr/dataimport? Command = full-import all data to the solr server for Indexing
Http: // localhost: 8081/solr/dataimport? Command = delta-import incremental import data
Http: // localhost: 8081/solr/dataimport? Command = status to view the running status
Http: // localhost: 8081/solr/dataimport? Command = reload-config can reload the configuration file
Terminate http: // localhost: 8080/solr/dataimport? Command = abort