The parsed query tree.
Unique positive term strings, in first-seen order.
// potassium hydroxide OR sodium carbonate
extractAllPositiveTerms(ast); // ["potassium hydroxide", "sodium carbonate"]
// Sodium AND NOT Borohydride
extractAllPositiveTerms(ast); // ["Sodium"]
export function extractAllPositiveTerms(ast: SearchAst): string[] {
return [...new Set(extractOrGroups(ast).flat())];
}
Flattens a query tree to its unique positive (non-negated) terms. Used by backends that only offer a single OR-ish full-text search field (e.g. Magento
search): send all positive terms as one query to get a broad candidate pool, then refine with the client-side boolean predicate.