简体   繁体   English

如何在多值字段中仅获取一个值的Solr文档?

[英]How can i get the solr documents with only one value in multi valued field?

I need to get the documents from solr index, where the documents has only one value in multivauled field. 我需要从Solr索引中获取文档,该文档在multivauled字段中只有一个值。

Say,following data in index. 说,以下是索引中的数据。

            <doc>
            <label>
            <id ="1">1</id>
            <id ="2">2</id>
            <label>
            </doc>
            <doc>
            <label>
            <id ="3">3</id>
            <label>
            </doc>

            <doc>
            <label>
            <id ="4">4</id>
            <id ="5">5</id>
            <label>
            </doc>
            <doc>
            <label>
            <id ="6">6</id>
            <label>
            </doc>

I need the following result, 我需要以下结果,

            <doc>
            <label>
            <id ="3">3</id>
            <label>
            </doc>

            <doc>
            <label>
            <id ="6">6</id>
            <label>
            </doc>

You can add Stateless Script Update Processor in your updateRequestProcessorChain which adds a new field to the document when that document has 1 value in the multi-valued field. 您可以在updateRequestProcessorChain中添加无状态脚本更新处理器,当该文档在多值字段中具有1值时,它将向该文档添加一个新字段。 Or you can use CountFieldValuesUpdateProcessorFactory < http://lucene.apache.org/solr/4_0_0/solr-core/org/apache/solr/update/processor/CountFieldValuesUpdateProcessorFactory.html > for counting search on basis of that field. 或者,您可以使用CountFieldValuesUpdateProcessorFactory < http://lucene.apache.org/solr/4_0_0/solr-core/org/apache/solr/update/processor/CountFieldValuesUpdateProcessorFactory.html >对该字段进行计数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM