Class SolrDocumentFetcher


  • public class SolrDocumentFetcher
    extends Object
    A helper class of SolrIndexSearcher for stored Document related matters including DocValue substitutions.
    • Method Detail

      • isLazyFieldLoadingEnabled

        public boolean isLazyFieldLoadingEnabled()
      • getDocumentCache

        public SolrCache<Integer,​org.apache.lucene.document.Document> getDocumentCache()
      • getStoredHighlightFieldNames

        public Collection<String> getStoredHighlightFieldNames()
        Returns a collection of the names of all stored fields which can be highlighted the index reader knows about.
      • getIndexedFieldNames

        public Collection<String> getIndexedFieldNames()
        Returns a collection of the names of all indexed fields which the index reader knows about.
      • doc

        public org.apache.lucene.document.Document doc​(int i,
                                                       Set<String> fields)
                                                throws IOException
        Retrieve the Document instance corresponding to the document id.

        NOTE: the document will have all fields accessible, but if a field filter is provided, only the provided fields will be loaded (the remainder will be available lazily).

        Throws:
        IOException
        See Also:
        SolrIndexSearcher.doc(int, Set)
      • solrDoc

        public org.apache.solr.common.SolrDocument solrDoc​(int luceneDocId,
                                                           SolrReturnFields solrReturnFields)
        This is an optimized version for populating a SolrDocument that:

        1. fetches all fields from docValues if possible. If no decompression of the stored data is necessary, we can avoid a disk seek and decompression cycle. This step is only used if all requested fields are {code docValues=true stored=false multiValued=false}. This last restriction because multiValued docValues fields do not faithfully reflect the input order in all cases. the values are returned and no decompression is necessary.

        2. if 1 is impossible, try to fetch all requested fields from the stored values. If the stored data has to be decompressed anyway, it's more efficient to just get all field values from the stored values. If we got all the requested fields, return.

        3. add fields where docValues=true stored=false thus could not be fetched in step 2

        Parameters:
        luceneDocId - The Lucene doc ID
        solrReturnFields - the structure holding the fields to be returned. The first time this method is called for a particular document list, it will be modified by adding a RetrieveFieldsOptimizer for use in future calls.
        Returns:
        The SolrDocument with values requested.

        This method is designed to be as simple as possible to use, just call it. e.g. {code SolrDocument sdoc = docFetcher.solrDoc(id, solrReturnFields);} then process the resulting SolrDocument as usual. Subsequent calls with the same solrReturnFields will re-use the optimizer created the first time.

        NOTE: DO NOT re-use the same SolrReturnFields object if the fields requested change.

      • decorateDocValueFields

        public void decorateDocValueFields​(org.apache.solr.common.SolrDocumentBase<?,​?> doc,
                                           int docid,
                                           Set<String> fields)
                                    throws IOException
        This will fetch and add the docValues fields to a given SolrDocument/SolrInputDocument
        Parameters:
        doc - A SolrDocument or SolrInputDocument instance where docValues will be added
        docid - The lucene docid of the document to be populated
        fields - The fields with docValues to populate the document with. DocValues fields which do not exist or not decodable will be ignored.
        Throws:
        IOException
      • getDvsCanSubstituteStored

        public Set<String> getDvsCanSubstituteStored()
      • getAllStored

        public Set<String> getAllStored()
      • getNonStoredDVs

        public Set<String> getNonStoredDVs​(boolean onlyUseDocValuesAsStored)
        Returns an unmodifiable set of non-stored docValues field names.
        Parameters:
        onlyUseDocValuesAsStored - If false, returns all non-stored docValues. If true, returns only those non-stored docValues which have the SchemaField.useDocValuesAsStored() flag true.
      • getNonStoredDVsWithoutCopyTargets

        public Set<String> getNonStoredDVsWithoutCopyTargets()
        Returns an unmodifiable set of names of non-stored docValues fields, except those that are targets of a copy field.