class documentation

class Pipeline: (source)

View In Hierarchy

lunr.Pipelines maintain a list of functions to be applied to all tokens in documents entering the search index and queries ran agains the index.

Class Method load Loads a previously serialised pipeline.
Class Method register_function Register a function with the pipeline.
Method __init__ Undocumented
Method __len__ Undocumented
Method __repr__ Undocumented
Method add Adds new functions to the end of the pipeline.
Method after Adds a single function after a function that already exists in the pipeline.
Method before Adds a single function before a function that already exists in the pipeline.
Method remove Removes a function from the pipeline.
Method reset Undocumented
Method run Runs the current list of functions that make up the pipeline against the passed tokens.
Method run_string Convenience method for passing a string through a pipeline and getting strings out. This method takes care of wrapping the passed string in a token and mapping the resulting tokens back to strings.
Method serialize Undocumented
Method skip Make the pipeline skip the function based on field name we're processing.
Method warn_if_function_not_registered Undocumented
Class Variable registered_functions Undocumented
Instance Variable _skip Undocumented
Instance Variable _stack Undocumented
@classmethod
def load(cls, serialised): (source)

Loads a previously serialised pipeline.

@classmethod
def register_function(cls, fn, label=None): (source)

Register a function with the pipeline.

def __init__(self): (source)

Undocumented

def __len__(self): (source)

Undocumented

def __repr__(self): (source)

Undocumented

def add(self, *args): (source)

Adds new functions to the end of the pipeline. Functions must accept three arguments: - Token: A lunr.Token object which will be updated - i: The index of the token in the set - tokens: A list of tokens representing the set

def after(self, existing_fn, new_fn): (source)

Adds a single function after a function that already exists in the pipeline.

def before(self, existing_fn, new_fn): (source)

Adds a single function before a function that already exists in the pipeline.

def remove(self, fn): (source)

Removes a function from the pipeline.

def reset(self): (source)

Undocumented

def run(self, tokens, field_name=None): (source)

Runs the current list of functions that make up the pipeline against the passed tokens. :param tokens: The tokens to process. :param field_name: The name of the field these tokens belongs to, can be ommited. Used to skip some functions based on field names.

def run_string(self, string, metadata=None): (source)

Convenience method for passing a string through a pipeline and getting strings out. This method takes care of wrapping the passed string in a token and mapping the resulting tokens back to strings. .. note:: This ignores the skipped functions since we can't access field names from this context.

def serialize(self): (source)

Undocumented

def skip(self, fn, field_names): (source)

Make the pipeline skip the function based on field name we're processing. This relies on passing the field name to Pipeline.run().

Parameters
fn:CallableUndocumented
field_names:List[str]Undocumented
def warn_if_function_not_registered(self, fn): (source)

Undocumented

registered_functions: Dict[str, Callable] = (source)

Undocumented

Undocumented

_stack: list = (source)

Undocumented