Solr中DIH模式的使用
Solr中使用DIH—ataImportHandler)模式
最早只是使用全量导入功能,即full-import
网上能搜索到的大部分demo多采用的情况是建立索引,查询,都是在同一个容器内操作,即开启同一个tomcat/jetty等
通过http请求中加入相应的参数即完成了相关操作,如:
http://localhost:8080/dataimport?command=full-import
http://localhost:8080/dataimport?command=delta-import
http://localhost:8080/solr/select/?q=*:*&version=2.2&start=0&rows=100&indent=on&group=true&group.field=albumId&group.ngroups=true
?
group用来分组,group.ngroups用来统计命中的数量,不过貌似这个东西比较慢
或者通过代码
?
?dataSource可以自定义,只需要继承
?
deltaQuery="select id,user_id from user_profile where gmt_modified > '${last_index_time}'"结果发现执行后的sql中last_index_time是空的,经过艰苦卓绝的跟踪代码发现,原来最后生成的?resolver对象中存放的数据(map)的key没有以last_index_time开头的,只有以dataimport为key的map为value,其中value中有lasta_index_time和item.last_index_time,所以当加上dataimport前缀后预期的结果出现了,也就是说其中的一些配置并不是随意的,有些属于固定配置,
?
还有就是pk的作用一直没搞懂,也是通过跟踪代码发现pk本身的作用只是保证查询出来的row放入map中的时候作为key使用的,所以么个entiy如果涉及到增量你就得有pk属性存在
具体的操作过程详见Solr中的DocBuilder这个类
?
solr搜索的时候使用类sql的group如下:
?
group=true&group.field=sellerId&group.format=simple其中sellerId是索引字段?
?
?
?
?
?
?
?
?
?
?
?