Solr dataimport详解
步骤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 文件
<?xml version="1.0" encoding="UTF-8" ?> <dataConfig> <dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://127.0.0.1:3306/test?test=true" user="test" password="123456"/> <document> <entity name="pc_keyword_associate" query=" SELECT zid as id ,key_word as kw,weight as weight FROM pc_keyword_associate "> <field column="id" name="id" /> <field column="weight" name="weight" /> <field column="kw" name="kw" /> </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
步骤4:
方法一:
启动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
方法二:
相关推荐
spylyt 2020-09-11
upxiaofeng 2020-06-11
TyCoding 2020-05-03
upxiaofeng 2020-04-30
lionelf 2020-04-20
TyCoding 2020-04-08
TyCoding 2020-03-26
wenchanter 2020-03-26
roygbip 2020-02-16
wsxsxz 2020-02-03
lionelf 2020-02-03
lionelf 2020-02-03
TyCoding 2020-02-01
heniancheng 2020-01-31
lionelf 2020-01-30
TyCoding 2020-01-10