Class DocTransformer

    • Constructor Detail

      • DocTransformer

        public DocTransformer()
    • Method Detail

      • getName

        public abstract String getName()
        Returns:
        The name of the transformer
      • getRawFields

        public Collection<String> getRawFields()
        If this transformer wants to bypass escaping in the TextResponseWriter and write content directly to output for certain field(s), the names of any such field(s) should be returned

        NOTE: normally this will be conditional on the `wt` param in the request, as supplied to the DocTransformer's parent TransformerFactory at 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.
      • transform

        public void transform​(org.apache.solr.common.SolrDocument doc,
                              int docid,
                              float score)
                       throws IOException
        This is where implementations do the actual work. If implementations require a valid docId and index access, the needsSolrIndexSearcher() method must return true

        Default implementation calls transform(SolrDocument, int).

        Parameters:
        doc - The document to alter
        docid - The Lucene internal doc id, or -1 in cases where the doc did not come from the index
        score - the score for this document
        Throws:
        IOException - If there is a low-level I/O error.
        See Also:
        needsSolrIndexSearcher()
      • transform

        public abstract void transform​(org.apache.solr.common.SolrDocument doc,
                                       int docid)
                                throws IOException
        This is where implementations do the actual work. If implementations require a valid docId and index access, the needsSolrIndexSearcher() method must return true
        Parameters:
        doc - The document to alter
        docid - The Lucene internal doc id, or -1 in cases where the doc did not come from the index
        Throws:
        IOException - If there is a low-level I/O error.
        See Also:
        needsSolrIndexSearcher()
      • getExtraRequestFields

        public String[] 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 the SolrIndexSearcher but may or may not be returned in the final QueryResponseWriter
        Returns:
        a list of extra lucene fields