2024-03-18 13:20:47 +01:00
|
|
|
import { defaultMatcher } from './query/matcher';
|
2024-05-29 04:54:45 +02:00
|
|
|
import { generateLexArray, generateLexResult } from './query/lex';
|
2024-03-18 13:20:47 +01:00
|
|
|
import { parseTokens } from './query/parse';
|
|
|
|
import { getAstMatcherForTerm } from './query/term';
|
|
|
|
|
|
|
|
function parseWithDefaultMatcher(term: string, fuzz: number) {
|
|
|
|
return getAstMatcherForTerm(term, fuzz, defaultMatcher);
|
|
|
|
}
|
|
|
|
|
2024-05-29 04:54:45 +02:00
|
|
|
export function parseSearch(query: string) {
|
2024-03-18 13:20:47 +01:00
|
|
|
const tokens = generateLexArray(query, parseWithDefaultMatcher);
|
|
|
|
return parseTokens(tokens);
|
|
|
|
}
|
|
|
|
|
2024-05-29 04:54:45 +02:00
|
|
|
export function getTermContexts(query: string) {
|
|
|
|
return generateLexResult(query, parseWithDefaultMatcher).termContexts;
|
|
|
|
}
|