/**
 * Search query clause
 */ export interface SearchQueryClause { presence : lunr . Query . presence ; term : string ; } /**
 * Search query terms
 */ export type SearchQueryTerms = Record < string , boolean > ; param value returns export function parseSearchQuery ( value ) { const query = new ( lunr as any ) . Query ( [ "title" , "text" ] ) ; const parser = new ( lunr as any ) . QueryParser ( value , query ) ; parser . parse ( ) ; return query . clauses ; } param query param terms returns export function getSearchQueryTerms ( query , terms ) { const clauses = new Set < SearchQueryClause > ( query ) ; const result = { } ; for ( let t = 0 ; t < terms . length ; t ++ ) for ( const clause of clauses ) if ( terms [ t ] . startsWith ( clause . term ) ) { result [ clause . term ] = true ; clauses . delete ( clause ) ; } for ( const clause of clauses ) if ( lunr . stopWordFilter ?. ( clause . term as any ) ) result [ clause . term ] = false ; return result ; }