diff --git a/types/lunr/index.d.ts b/types/lunr/index.d.ts index 415c7c1d8f..ab59d556f6 100644 --- a/types/lunr/index.d.ts +++ b/types/lunr/index.d.ts @@ -535,6 +535,24 @@ declare namespace lunr { } namespace Query { + /** + * Constants for indicating what kind of presence a term must have in matching documents. + */ + enum presence { + /** + * Term's presence in a document is optional, this is the default value. + */ + OPTIONAL = 1, + /** + * Term's presence in a document is required, documents that do not contain this term will not be returned. + */ + REQUIRED = 2, + /** + * Term's presence in a document is prohibited, documents that do contain this term will not be returned. + */ + PROHIBITED = 3 + } + enum wildcard { NONE = 0, LEADING = 1 << 0, @@ -598,6 +616,12 @@ declare namespace lunr { * Adds a term to the current query, under the covers this will create a {@link lunr.Query~Clause} * to the list of clauses that make up this query. * + * The term is used as is, i.e. no tokenization will be performed by this method. Instead conversion + * to a token or token-like string should be done before calling this method. + * + * The term will be converted to a string by calling `toString`. Multiple terms can be passed as an + * array, each term in the array will share the same options. + * * @param term - The term to add to the query. * @param [options] - Any additional properties to add to the query clause. * @see lunr.Query#clause @@ -611,7 +635,7 @@ declare namespace lunr { * wildcard: lunr.Query.wildcard.TRAILING * }) */ - term(term: string, options: object): Query; + term(term: string | string[] | Token | Token[], options: object): Query; } class QueryParseError extends Error { diff --git a/types/lunr/lunr-tests.ts b/types/lunr/lunr-tests.ts index a14fd1947f..4d3fa57461 100644 --- a/types/lunr/lunr-tests.ts +++ b/types/lunr/lunr-tests.ts @@ -25,6 +25,16 @@ function basic_test() { }); index.search("foo"); + + index.query(q => { + q.term( + lunr.tokenizer('search terms'), + { + wildcard: lunr.Query.wildcard.TRAILING, + presence: lunr.Query.presence.REQUIRED + } + ); + }); } function pipeline_test() {