solr data-config.xml配置文件的见解mysql数据源

陆续完善:

http://localhost:8080/solr 进行DataImport时 找不到数据库中的entity

检查一下dataSource中的url

<dataSource type="JdbcDataSource" name="chishang" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://xxx.mysql.rds.aliyuncs.com/wjs?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8" user="xxxx" password="xxxx" />

一般都能用。如果不能用 将后面的编码格式去掉 试试看

<dataSource type="JdbcDataSource" name="chishang" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://xxxxx.mysql.rds.aliyuncs.com/wjs" user="xxxx" password="xxxx" />


data-config.xml配置文件

<entity name="product" dataSource="chishang"query="select id,'艺术品' cat,artists,content 'introduction',DATE_FORMAT(last_modified,'%Y-%m-%d')last_modified,focus,price,size,title,weight,proClassId,cast(concat('p',id) as char) as dockey fromproduct where deleted=false"


deltaImportQuery="select id,'%Y-%m-%d') last_modified,id) as char) as dockey from product where cast(concat('p',id) as char)='${dih.delta.dockey}'"


deltaQuery="select cast(concat('p',id) as char) in (select cast(concat('p',id) as char) from product_class where
last_modified>'${dih.last_index_time}') or last_modified &gt; '${dih.last_index_time}'"> //注意这里才是entity的结束括号

<entity name="product_picture" query="select path 'icon' from product_picture_tbl where productId='${product.id}'"> </entity>


</entity>

解释说明
(1):query中select哪些字段 a.为产品product表中哪些字段需要作为搜索的内容
b.内嵌的entity中需要用到的字段如:<entity name="product_picture"query="select path 'icon' from product_picture_tbl where
productId='${product. id }'"></entity> 中的'${product.id}'中的 id ,必须在query 进行select的时候筛选 出来。


(2):deltaQuery解释:从product表(或者product中内嵌的entity)中查找last_modifed时间大于solr配置文件dataimport.properties中的最 后一次修改时间。把需要修改的id都查找出来。例如:
deltaQuery="select cast(concat('p',id) as char) from product_class where
last_modified>'${dih.last_index_time}') or last_modified &gt; '${dih.last_index_time}'"> product表中的last_modified>'${dih.last_index_time} 同时product_class表中的

last_modified>'${dih.last_index_time} 可能有点难理解,可以看solr官网。


(3):deltaImportQuery的理解

deltaImportQuery="select id,id) as char) as dockey from product wherecast(concat('p',id) as char)='${dih.delta.dockey}'"


cast(concat('p',id) as char) 为最外层entity的主键
${dih.delta.dockey} 中的dockey为deltaquery查询时的主键


deltaQuery是用来确认有没有记录要导入的,一般只返回记录ID.
deltaImportQuery是已经确认有记录要导入的情况下,用来获取要导入的记录所有属性的,是依据deltaQuery的ID来确定的。

意味着:deltaQuery返回了多少个ID,就会执行多少次deltaImportQuery

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念
xml文件介绍及使用
xml编程(一)-xml语法
XML文件结构和基本语法
第2章 包装类
XML入门的常见问题(二)
Java对象的强、软、弱和虚引用
JS解析XML文件和XML字符串详解
java中枚举的详细使用介绍
了解Xml格式
XML入门的常见问题(四)
深入SQLite多线程的使用总结详解
PlayFramework完整实现一个APP(一)
XML和YAML的使用方法
XML轻松学习总节篇