public final class CountFieldValuesUpdateProcessorFactory extends FieldMutatingUpdateProcessorFactory
Replaces any list of values for a field matching the specified conditions with the 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 the category
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 the
category_count
field, because
CountFieldValuesUpdateProcessorFactory
only replaces the
list of values with the size of that list. If
DefaultValueUpdateProcessorFactory
was not used, then any
document that had no values for the category
field, would also
have no value in the category_count
field.
FieldMutatingUpdateProcessorFactory.SelectorParams
UpdateRequestProcessorFactory.RunAlways
Constructor and Description |
---|
CountFieldValuesUpdateProcessorFactory() |
Modifier and Type | Method and Description |
---|---|
UpdateRequestProcessor |
getInstance(SolrQueryRequest req,
SolrQueryResponse rsp,
UpdateRequestProcessor next) |
getBooleanArg, getDefaultSelector, getSelector, inform, init, oneOrMany, parseSelectorExclusionParams, parseSelectorParams
public CountFieldValuesUpdateProcessorFactory()
public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next)
getInstance
in class UpdateRequestProcessorFactory
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.