ChemPal Documentation - v1.6.0
    Preparing search index...
    • 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.

      Parameters

      Returns string[]

      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())];
      }