This module contains classes that allow reading from an index.
Do not instantiate this object directly. Instead use Index.reader().
Returns an iterator of all (undeleted) document IDs in the reader.
Yields the stored fields for all documents.
Yields (fieldname, text) tuples for every term in the index.
Closes the open files associated with this reader.
Tells the reader to remember a set of facets under the given name.
Parameters: |
|
---|
Returns the total number of UNDELETED documents in this reader.
Returns the total number of documents, DELETED OR UNDELETED, in this reader.
Returns the number of terms in the given field in the given document. This is used by some scoring algorithms.
Returns an iterator of (fieldname, length) pairs for the given document. This is used internally.
Returns how many documents the given term appears in.
Yields terms in the given field that start with the given prefix.
Returns the total number of terms in the given field. This is used by some scoring algorithms.
Returns the first ID in the posting list for the given term. This may be optimized in certain backends.
Returns the total number of instances of the given term in the collection.
Returns the generation of the index being read, or -1 if the backend is not versioned.
Returns a dictionary mapping field values to items with that value in the given field(s).
Parameters: |
|
---|
Returns True if the underlying index/segment has deleted documents.
Returns True if the given document has a term vector for the given field.
Returns True if the given document number is marked deleted.
Yields (text, doc_freq, index_freq) tuples for all terms in the given field.
Yields (field_num, text, doc_freq, index_freq) tuples for all terms in the reader, starting at the given term.
Yields (field_num, text, doc_freq, index_freq) tuples for all terms in the given field with a certain prefix.
Returns a sequence of (sorting_key, docnum) pairs for the document numbers in docnum.
If limit is None, this method associates every document number with a sorting key but does not sort them. If limit is not None, this method returns a sorted list of at most limit pairs.
This method is useful for sorting and faceting documents in different readers, by associating the sort key with the document number.
Parameters: |
|
---|
Returns a list of (IndexReader, docbase) pairs for the child readers of this reader if it is a composite reader, or None if this reader is atomic.
Yields all terms in the given field.
Returns the maximum length of the field across all documents.
Returns the top ‘number’ terms with the highest tf*idf scores as a list of (score, text) tuples.
Returns the top ‘number’ most frequent terms in the given field as a list of (frequency, text) tuples.
Returns a Matcher for the postings of the given term.
>>> pr = reader.postings("content", "render")
>>> pr.skip_to(10)
>>> pr.id
12
Parameters: |
|
---|---|
Return type: |
Sets the field caching policy for this reader.
Returns a version of docnums sorted by the value of a field or a set of fields in each document.
Parameters: |
|
---|
Returns the stored fields for the given document number.
Parameters: | numerickeys – use field numbers as the dictionary keys instead of field names. |
---|
Returns True if this reader supports the field cache protocol.
Returns a Matcher object for the given term vector.
>>> docnum = searcher.document_number(path=u'/a/b/c')
>>> v = searcher.vector(docnum, "content")
>>> v.all_as("frequency")
[(u"apple", 3), (u"bear", 2), (u"cab", 2)]
Parameters: |
|
---|---|
Return type: |
Returns an iterator of (termtext, value) pairs for the terms in the given term vector. This is a convenient shortcut to calling vector() and using the Matcher object when all you want are the terms and/or values.
>>> docnum = searcher.document_number(path=u'/a/b/c')
>>> searcher.vector_as("frequency", docnum, "content")
[(u"apple", 3), (u"bear", 2), (u"cab", 2)]
Parameters: |
|
---|
Do not instantiate this object directly. Instead use Index.reader().