Interface TransformerFactory.FieldRenamer
-
- All Known Implementing Classes:
GeoTransformerFactory,RawValueTransformerFactory
- Enclosing class:
- TransformerFactory
public static interface TransformerFactory.FieldRenamerTheTransformerFactory.FieldRenamerinterface should be implemented by anyTransformerFactorycapable of generating transformers that might rename fields, and should implementcreate(String, SolrParams, SolrQueryRequest, Map, Set)in place ofTransformerFactory.create(String, SolrParams, SolrQueryRequest)(with the latter method overridden to throwUnsupportedOperationException).DocTransformers returned viacreate(String, SolrParams, SolrQueryRequest, Map, Set)will be added in a second pass, allowing simplified logic inTransformerFactory.create(String, SolrParams, SolrQueryRequest)for non-renaming factories.create(String, SolrParams, SolrQueryRequest, Map, Set)must implement extra logic to be aware of preceding field renames, and to make subsequentTransformerFactory.FieldRenamertransformers aware of its own field renames.It is harmless for a
DocTransformerthat does _not_ in practice rename fields to be returned from a factory that implements this interface (e.g., for conditional renames?); but doing so opens the possibility ofcreate(String, SolrParams, SolrQueryRequest, Map, Set)being called _after_ fields have been renamed, so such implementations must still check whether the field with which they are concerned has been renamed ... and if it _has_, must copy the field back to its original name. This situation also demonstrates the motivation for separating the creation ofDocTransformers into two phases: an initial phase involving no field renames, and a subsequent phase that implement extra logic to properly handle field renames.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description DocTransformercreate(String field, org.apache.solr.common.params.SolrParams params, SolrQueryRequest req, Map<String,String> renamedFields, Set<String> reqFieldNames)Analogous toTransformerFactory.create(String, SolrParams, SolrQueryRequest), but to be implemented byTransformerFactorys that produceDocTransformers that may rename fields.default booleanmayModifyValue()Returnstrueif implementations of this class may (even subtly) modify field values.
-
-
-
Method Detail
-
create
DocTransformer create(String field, org.apache.solr.common.params.SolrParams params, SolrQueryRequest req, Map<String,String> renamedFields, Set<String> reqFieldNames)
Analogous toTransformerFactory.create(String, SolrParams, SolrQueryRequest), but to be implemented byTransformerFactorys that produceDocTransformers that may rename fields.- Parameters:
field- The destination fieldparams- Local params associated with this transformer (e.g., source field)req- The current requestrenamedFields- Maps source=>dest renamed fields. Implementations should check this first, updating their own "source" field(s) as necessary, and if renaming (not copying) fields, should also update this map with the implementations "own" introduced source=>dest field mappingreqFieldNames- Set of explicitly requested field names; implementations should consult this set to determine whether it's appropriate to rename (vs. copy) a field (e.g.:boolean copy = reqFieldNames != null && reqFieldNames.contains(sourceField))- Returns:
- A transformer to be used in processing field values in returned documents.
-
mayModifyValue
default boolean mayModifyValue()
Returnstrueif implementations of this class may (even subtly) modify field values. (GeoTransformerFactorymay do this, e.g.). To fail safe, the default implementation returnstrue. This method should be overridden to returnfalseif the implementing class is guaranteed to not modify any values for the fields that it renames.
-
-