Class: Query

lunr.Query

new Query()

A lunr.Query provides a programtic way of defining queries to be perfomed against a lunr.Index.

Prefer constructing a lunr.Query using the lunr.Index#query method so the query object is pre-initialized with the right index fields.

Properties:
Name Type Description
clauses Array.<lunr.Query~Clause>

An array of query clauses.

allFields Array.<string>

An array of all available fields in a lunr.Index.

Source:

Methods

clause(clause) → {lunr.Query}

Adds a lunr.Query~Clause to this query.

Unless the clause contains the fields to be matched all fields will be matched. In addition a default boost of 1 is applied to the clause.

Parameters:
Name Type Description
clause lunr.Query~Clause

The clause to add to this query.

Source:
Returns:
Type
lunr.Query

term(term, optionsopt) → {lunr.Query}

Adds a term to the current query, under the covers this will create a lunr.Query~Clause to the list of clauses that make up this query.

Parameters:
Name Type Attributes Description
term string

The term to add to the query.

options Object <optional>

Any additional properties to add to the query clause.

Source:
Returns:
Type
lunr.Query

Type Definitions

Clause

A single clause in a lunr.Query contains a term and details on how to match that term against a lunr.Index.

Type:
  • Object
Properties:
Name Type Attributes Description
fields Array.<string>

The fields in an index this clause should be matched against.

boost number

Any boost that should be applied when matching this clause.

editDistance number <optional>

Whether the term should have fuzzy matching applied, and how fuzzy the match should be.

hasWildcard boolean <optional>

Whether the term to be matched contains a wildcard.

Source: