ChemPal Documentation - v1.18.0
    Preparing search index...

    Module utils/search-query/extractPositiveTerms

    Search - Utils

    extractOrGroups

    Extracts the positive (non-negated) OR-groups from a query tree as a disjunctive-normal-form-ish list: the outer array is OR-ed alternatives, and each inner array is an AND-group of phrases. Negated branches are dropped, since a keyword-only backend has nothing positive to search for in them.

    extractAllPositiveTerms

    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.

    extractReagentNames

    Expands a query tree into the distinct reagent names it searches for. Each positive AND-group (see extractOrGroups) becomes one name by joining its words with a space, so (sodium OR potassium) hydroxide OR potassium carbonate yields three names. Bare purity tokens like 99% are dropped, and names are de-duplicated case-insensitively.