在data-config.xml中:
<entity name="index" query="select distinct index from (SELECT distinct index FROM street WHERE (substr(code::text, 1, 8)::character varying(8)) = substr('${kladr.code}', 1, 11)
union all
SELECT distinct index FROM kladr WHERE (substr(code::text, 1, 8)::character varying(8)) = substr('${kladr.code}', 1, 8)
union all
SELECT distinct index from street_zip where (substr(code::text, 1, 8)::character varying(8)) = substr('${kladr.code}', 1, 11)
union all
SELECT distinct index from street_building where (substr(parent_code::text, 1, 8)::character varying(8)) = substr('${kladr.code}', 1, 8)) as t
"
transformer="LogTransformer" logTemplate="street: ${index.index}" logLevel="debug">
</entity>
我需要单独的实体“index_count”和实体“index”中的记录数(它是多值字段)。如果我进行另一个SQL查询会减慢数据导入速度,我可以使用实体从中提取数据吗?例如:
<entity name="index_count" query="SELECT count(*) from index">
</entity>
还是这样的?
答案 0 :(得分:2)
可能不是唯一的方法,但你可以添加一个Update+Request+Processor来计算数字并填充index_count字段。
它会很快,但实现起来比较复杂,需要编写java代码。如果您使用的是Solrcloud,则需要将代码部署到所有节点等