【问题标题】:How to use data from one field in another field in Solr?如何在 Solr 的另一个字段中使用来自一个字段的数据?
【发布时间】:2017-05-23 11:57:40
【问题描述】:

在 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>

还是这样的?

【问题讨论】:

    标签: solr


    【解决方案1】:

    可能不是唯一的方法,但您可以添加一个Update+Request+Processor,它计算数字并填充 index_count 字段。

    会很快,但是实现起来比较复杂,需要写java代码。如果您使用 Solrcloud,则需要将代码部署到所有节点等

    【讨论】:

    • 要使用 URP 计算多值字段中的值的数量,您可以使用 CloneFieldUpdateProcessorFactory 后跟 CountFieldValuesUpdateProcessorFactory 并可能使用 DefaultValueUpdateProcessorFactory(尽管您可以在字段定义上设置默认值)。 URP 的完整列表可以在以下位置找到:solr-start.com/info/update-request-processors
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-12
    • 1970-01-01
    • 2018-03-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多