Class DocTransformer
- Direct Known Subclasses:
BaseEditorialTransformer,DocTransformer.NoopFieldTransformer,DocTransformers,OriginalScoreAugmenter,RenameFieldTransformer,ScoreAugmenter,ValueAugmenterFactory.ValueAugmenter,ValueSourceAugmenter
QueryElevationComponent)
New instance for each request
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classTrivial Impl that ensure that the specified field is requested as an "extra" field, but then does nothing during the transformation phase. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionString[]When a transformer needs access to fields that are not automatically derived from the input fields names, this option lets us explicitly say the field names that we hope will be in the SolrDocument.abstract StringgetName()If this transformer wants to bypass escaping in theTextResponseWriterand write content directly to output for certain field(s), the names of any such field(s) should be returnedbooleanIndicates if this transformer requires access to the underlying index to perform it's functions.voidsetContext(ResultContext context) This is called beforetransform(org.apache.solr.common.SolrDocument, int, org.apache.solr.search.DocIterationInfo)to provide context for any subsequent transformations.toString()abstract voidtransform(org.apache.solr.common.SolrDocument doc, int docid, DocIterationInfo docInfo) This is where implementations do the actual work.
-
Field Details
-
context
-
-
Constructor Details
-
DocTransformer
public DocTransformer()
-
-
Method Details
-
getName
- Returns:
- The name of the transformer
-
setContext
This is called beforetransform(org.apache.solr.common.SolrDocument, int, org.apache.solr.search.DocIterationInfo)to provide context for any subsequent transformations.- Parameters:
context- TheResultContextstores information about how the documents were produced.- See Also:
-
getRawFields
If this transformer wants to bypass escaping in theTextResponseWriterand write content directly to output for certain field(s), the names of any such field(s) should be returnedNOTE: normally this will be conditional on the `wt` param in the request, as supplied to the
DocTransformer's parentTransformerFactoryat the time of transformer creation.- Returns:
- Collection containing field names to be written raw; if no field names should be
written raw, an empty collection should be returned. Any collection returned collection
need not be externally modifiable -- i.e.,
Collections.singleton(Object)is acceptable.
-
needsSolrIndexSearcher
public boolean needsSolrIndexSearcher()Indicates if this transformer requires access to the underlying index to perform it's functions.In some situations (notably RealTimeGet) this method may be called before
setContext(org.apache.solr.response.ResultContext)to determine if the transformer must be given a "full" ResultContext and accurate docIds that can be looked up usingResultContext.getSearcher(), or if optimizations can be taken advantage of such thatResultContext.getSearcher()may return null, and docIds passed totransform(org.apache.solr.common.SolrDocument, int, org.apache.solr.search.DocIterationInfo)may be negative.The default implementation always returns
false.- See Also:
-
transform
public abstract void transform(org.apache.solr.common.SolrDocument doc, int docid, DocIterationInfo docInfo) throws IOException This is where implementations do the actual work. If implementations require a valid docId and index access, theneedsSolrIndexSearcher()method must return true- Parameters:
doc- The document to alterdocid- The Lucene internal doc id, or -1 in cases where thedocdid not come from the indexdocInfo- the document information for this document, including the score. Do not passnull, instead useDocIterationInfo.NONE.- Throws:
IOException- If there is a low-level I/O error.- See Also:
-
getExtraRequestFields
When a transformer needs access to fields that are not automatically derived from the input fields names, this option lets us explicitly say the field names that we hope will be in the SolrDocument. These fields will be requested from theSolrIndexSearcherbut may or may not be returned in the finalQueryResponseWriter- Returns:
- a list of extra lucene fields
-
toString
-