class documentation

An index contains the built index of all documents and provides a query interface to the index. Usually instances of lunr.Index will not be created using this constructor, instead lunr.Builder should be used to construct new indexes, or lunr.Index.load should be used to load previously built and serialized indexes.

Class Method load Load a serialized index
Method __eq__ Undocumented
Method __init__ Undocumented
Method create_query Convenience method to create a Query with the Index's fields.
Method query Performs a query against the index using the passed lunr.Query object.
Method search Performs a search against the index using lunr query syntax.
Method serialize Returns a serialized index as a dict following lunr-schema.
Instance Variable field_vectors Undocumented
Instance Variable fields Undocumented
Instance Variable inverted_index Undocumented
Instance Variable pipeline Undocumented
Instance Variable token_set Undocumented
@classmethod
def load(cls, serialized_index): (source)

Load a serialized index

def __eq__(self, other): (source)

Undocumented

def __init__(self, inverted_index, field_vectors, token_set, fields, pipeline): (source)

Undocumented

def create_query(self, fields=None): (source)

Convenience method to create a Query with the Index's fields. Args: fields (iterable, optional): The fields to include in the Query, defaults to the Index's `all_fields`. Returns: Query: With the specified fields or all the fields in the Index.

def query(self, query=None, callback=None): (source)

Performs a query against the index using the passed lunr.Query object. If performing programmatic queries against the index, this method is preferred over `lunr.Index.search` so as to avoid the additional query parsing overhead. Args: query (lunr.Query): A configured Query to perform the search against, use `create_query` to get a preconfigured object or use `callback` for convenience. callback (callable): An optional function taking a single Query object result of `create_query` for further configuration.

def search(self, query_string): (source)

Performs a search against the index using lunr query syntax. Results will be returned sorted by their score, the most relevant results will be returned first. For more programmatic querying use `lunr.Index.query`. Args: query_string (str): A string to parse into a Query. Returns: dict: Results of executing the query.

def serialize(self): (source)

Returns a serialized index as a dict following lunr-schema.

field_vectors = (source)

Undocumented

fields = (source)

Undocumented

inverted_index = (source)

Undocumented

pipeline = (source)

Undocumented

token_set = (source)

Undocumented