Interface TransformerFactory.FieldRenamer
-
- All Known Implementing Classes:
GeoTransformerFactory
,RawValueTransformerFactory
- Enclosing class:
- TransformerFactory
public static interface TransformerFactory.FieldRenamer
TheTransformerFactory.FieldRenamer
interface should be implemented by anyTransformerFactory
capable 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
).DocTransformer
s 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.FieldRenamer
transformers aware of its own field renames.It is harmless for a
DocTransformer
that 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 ofDocTransformer
s 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 DocTransformer
create(String field, SolrParams params, SolrQueryRequest req, Map<String,String> renamedFields, Set<String> reqFieldNames)
Analogous toTransformerFactory.create(String, SolrParams, SolrQueryRequest)
, but to be implemented byTransformerFactory
s that produceDocTransformer
s that may rename fields.default boolean
mayModifyValue()
Returnstrue
if implementations of this class may (even subtly) modify field values.
-
-
-
Method Detail
-
create
DocTransformer create(String field, SolrParams params, SolrQueryRequest req, Map<String,String> renamedFields, Set<String> reqFieldNames)
Analogous toTransformerFactory.create(String, SolrParams, SolrQueryRequest)
, but to be implemented byTransformerFactory
s that produceDocTransformer
s 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()
Returnstrue
if implementations of this class may (even subtly) modify field values. (GeoTransformerFactory
may do this, e.g.). To fail safe, the default implementation returnstrue
. This method should be overridden to returnfalse
if the implementing class is guaranteed to not modify any values for the fields that it renames.
-
-