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 > '${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的时候筛选 出来。
deltaQuery="select cast(concat('p',id) as char) from product_class where last_modified>'${dih.last_index_time}') or last_modified > '${dih.last_index_time}'"> product表中的last_modified>'${dih.last_index_time} 同时product_class表中的 last_modified>'${dih.last_index_time} 可能有点难理解,可以看solr官网。
deltaImportQuery="select id,id) as char) as dockey from product wherecast(concat('p',id) as char)='${dih.delta.dockey}'"
${dih.delta.dockey} 中的dockey为deltaquery查询时的主键 deltaQuery是用来确认有没有记录要导入的,一般只返回记录ID. deltaImportQuery是已经确认有记录要导入的情况下,用来获取要导入的记录所有属性的,是依据deltaQuery的ID来确定的。 意味着:deltaQuery返回了多少个ID,就会执行多少次deltaImportQuery (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |