solr增量索引
參考:http://wiki.apache.org/solr/DataImportHandler#Using_delta-import_command
修改qiye-data-config.xml
<dataConfig><dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver"url="jdbc:mysql://localhost:3306/qiye"user="root" password="root"/><document><entity name="id" pk="id"query="select id,shopdesc from testshop"deltaImportQuery="select * from testshop where ID='${dih.delta.id}'"deltaQuery="select id from testshop where last_modified > '${dih.last_index_time}'"></entity></document> </dataConfig>表中testshop加入了字段last_modified 為timestamp類型,默認CURRENT_TIMESTAMP
The query gives the data needed to populate fields of the Solr document in full-import The deltaImportQuery gives the data needed to populate fields when running a delta-import The deltaQuery gives the primary keys of the current entity which have changes since the last index time The parentDeltaQuery uses the changed rows of the current table (fetched with deltaQuery) to give the changed rows in the parent table.This is necessary because whenever a row in the child table changes, we need to re-generate the document which has that field.運行:
http://localhost:8080/solr/dataimport?command=delta-import?導入新加入的數據,
http://localhost:8080/solr/#/collection1/query?就可以查詢出剛才新加入的數據
關于定時索引,查看文檔http://wiki.apache.org/solr/DataImportHandler#Scheduling
這里也發現了有人對這個進行了封裝:https://code.google.com/p/solr-dataimport-scheduler/
轉載于:https://www.cnblogs.com/atyou/archive/2013/04/20/3032895.html
總結
- 上一篇: IE8属性选择器
- 下一篇: 当前监管面比较关注的企业征信模型