class Index: (source)
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 |
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 |
Undocumented |
Instance Variable | fields |
Undocumented |
Instance Variable | inverted |
Undocumented |
Instance Variable | pipeline |
Undocumented |
Instance Variable | token |
Undocumented |
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.
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.
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.