2440 发表于 2016-12-16 06:59:38

solr data import config

solr的dataimporthandler 配置, 全量和增量导入,


<?xml version="1.0" encoding="UTF-8" ?>
<dataConfig>
<dataSourcetype="JdbcDataSource" driver="org.postgresql.Driver" url="jdbc:postgresql://localhost/postgres" user="xxxxxx" password="xxxxxx" encoding="UTF-8" />
<document>

<!--deletedPkQuery="select id from table" detetePkQuery这个查询把已经删除的id查询出来,表里面存有已经删除的id-->
<entity name="users" pk="id" query="select * from users"
deltaQuery="select id from users where last_modified > '${dataimporter.last_index_time}'"
deltaImportQuery="select id,name from users where ID=${dataimporter.delta.id}">
<field column="ID" name="id"/>
<field column="NAME" name="name" />
<!--一对多配置,-->
<entity name="userinfo"pk="id"
query="select * from USERINFO where userid=${users.id}"
deltaQuery="select id,userid from USERINFO where last_modified > '${dataimporter.last_index_time}'"
parentDeltaQuery="select id from USERS where ID=${userinfo.userid}"
deltaImportQuery="select info from userinfo where ID=${dataimporter.delta.id}">
<field name="info" column="info" />
</entity>
</entity>
</document>
</dataConfig>


附上数据库建表语句

CREATE TABLE users
(
id integer NOT NULL,
name character(50),
last_modified timestamp without time zone,
CONSTRAINT users_pkey PRIMARY KEY (id)
)
WITHOUT OIDS;
ALTER TABLE users OWNER TO postgres;

drop table userinfo;
CREATE TABLE userinfo
(
id integer NOT NULL,
info character(50),
userid integer,
last_modified timestamp without time zone,
CONSTRAINT userinfo_pkey PRIMARY KEY (id),
CONSTRAINT userinfo_userid_fkey FOREIGN KEY (userid)
REFERENCES users (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
页: [1]
查看完整版本: solr data import config