Class SolrDocumentFetcher
- java.lang.Object
-
- org.apache.solr.search.SolrDocumentFetcher
-
public class SolrDocumentFetcher extends Object
A helper class ofSolrIndexSearcher
for stored Document related matters including DocValue substitutions.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SolrDocumentFetcher
clone()
void
decorateDocValueFields(org.apache.solr.common.SolrDocumentBase<?,?> doc, int docid, Set<String> fields, DocValuesIteratorCache reuseDvIters)
This will fetch and add the docValues fields to a given SolrDocument/SolrInputDocumentorg.apache.lucene.document.Document
doc(int docId)
org.apache.lucene.document.Document
doc(int i, Set<String> fields)
Retrieve theDocument
instance corresponding to the document id.void
doc(int docId, org.apache.lucene.index.StoredFieldVisitor visitor)
Visit a document's fields using aStoredFieldVisitor
.Set<String>
getAllStored()
SolrCache<Integer,org.apache.lucene.document.Document>
getDocumentCache()
Set<String>
getDvsCanSubstituteStored()
Collection<String>
getIndexedFieldNames()
Returns a collection of the names of all indexed fields which the index reader knows about.Set<String>
getNonStoredDVs(boolean onlyUseDocValuesAsStored)
Returns an unmodifiable set of non-stored docValues field names.Set<String>
getNonStoredDVsWithoutCopyTargets()
Returns an unmodifiable set of names of non-stored docValues fields, except those that are targets of a copy field.Collection<String>
getStoredHighlightFieldNames()
Returns a collection of the names of all stored fields which can be highlighted the index reader knows about.boolean
isLazyFieldLoadingEnabled()
org.apache.solr.common.SolrDocument
solrDoc(int luceneDocId, SolrReturnFields solrReturnFields)
This is an optimized version for populating a SolrDocument that:
-
-
-
Method Detail
-
clone
protected SolrDocumentFetcher clone()
-
isLazyFieldLoadingEnabled
public boolean isLazyFieldLoadingEnabled()
-
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 docId) throws IOException
- Throws:
IOException
- See Also:
SolrIndexSearcher.doc(int)
-
doc
public org.apache.lucene.document.Document doc(int i, Set<String> fields) throws IOException
Retrieve theDocument
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 IDsolrReturnFields
- 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.
-
doc
public void doc(int docId, org.apache.lucene.index.StoredFieldVisitor visitor) throws IOException
Visit a document's fields using aStoredFieldVisitor
.- Throws:
IOException
-
decorateDocValueFields
public void decorateDocValueFields(org.apache.solr.common.SolrDocumentBase<?,?> doc, int docid, Set<String> fields, DocValuesIteratorCache reuseDvIters) 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 addeddocid
- The lucene docid of the document to be populatedfields
- The fields with docValues to populate the document with. DocValues fields which do not exist or not decodable will be ignored.- Throws:
IOException
-
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 theSchemaField.useDocValuesAsStored()
flag true.
-
-