Class CountFieldValuesUpdateProcessorFactory
- java.lang.Object
-
- org.apache.solr.update.processor.UpdateRequestProcessorFactory
-
- org.apache.solr.update.processor.FieldMutatingUpdateProcessorFactory
-
- org.apache.solr.update.processor.CountFieldValuesUpdateProcessorFactory
-
- All Implemented Interfaces:
NamedListInitializedPlugin
,SolrCoreAware
public final class CountFieldValuesUpdateProcessorFactory extends FieldMutatingUpdateProcessorFactory
Replaces any list of values for a field matching the specified conditions with the count of the number of values for that field.By default, this processor matches no fields.
The typical use case for this processor would be in combination with the
CloneFieldUpdateProcessorFactory
so that it's possible to query by the quantity of values in the source field.For example, in the configuration below, the end result will be that the
category_count
field can be used to search for documents based on how many values they contain in thecategory
field.<processor class="solr.CloneFieldUpdateProcessorFactory"> <str name="source">category</str> <str name="dest">category_count</str> </processor> <processor class="solr.CountFieldValuesUpdateProcessorFactory"> <str name="fieldName">category_count</str> </processor> <processor class="solr.DefaultValueUpdateProcessorFactory"> <str name="fieldName">category_count</str> <int name="value">0</int> </processor>
NOTE: The use of
DefaultValueUpdateProcessorFactory
is important in this example to ensure that all documents have a value for thecategory_count
field, becauseCountFieldValuesUpdateProcessorFactory
only replaces the list of values with the size of that list. IfDefaultValueUpdateProcessorFactory
was not used, then any document that had no values for thecategory
field, would also have no value in thecategory_count
field.- Since:
- 4.0.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.solr.update.processor.FieldMutatingUpdateProcessorFactory
FieldMutatingUpdateProcessorFactory.SelectorParams
-
Nested classes/interfaces inherited from class org.apache.solr.update.processor.UpdateRequestProcessorFactory
UpdateRequestProcessorFactory.RunAlways
-
-
Constructor Summary
Constructors Constructor Description CountFieldValuesUpdateProcessorFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UpdateRequestProcessor
getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next)
-
Methods inherited from class org.apache.solr.update.processor.FieldMutatingUpdateProcessorFactory
getDefaultSelector, getSelector, inform, init, parseSelectorExclusionParams, parseSelectorParams
-
-
-
-
Method Detail
-
getInstance
public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next)
- Specified by:
getInstance
in classUpdateRequestProcessorFactory
-
-