ChemPal Documentation - v1.6.0
    Preparing search index...
    • Runs an advanced (boolean) query against every cached product title through the real parseSearchQueryscoreAstMatch path, showing which titles the predicate keeps, which it drops and why, and which drops hinge on fuzzyWords.

      Parameters

      • query: string

        The search string; may use AND/OR/NOT and parentheses.

      • options: AstProbeOptions = {}

        source ("cache" / "results" / "both"), suppliers, limit (0 = all), ranking scorer, threshold, fuzzyWords, and compareFuzzyWords.

      Returns Promise<AstProbeResult>

      The full evaluated result, also printed unless print: false.

      // In the console:
      const result = await chempal.astTest("sodium AND NOT borohydride");
      result.astText; // => '(sodium AND NOT borohydride)'
      result.matched.length; // => 37
      result.dropped[0].failedTerms; // => ['sodium']

      await chempal.astTest("acid OR base", { fuzzyWords: false, threshold: 70 });
      await chempal.astTest("sodium", { suppliers: "loud", source: "cache", limit: 0 });
      export async function astTest(
      query: string,
      options: AstProbeOptions = {},
      ): Promise<AstProbeResult> {
      const corpus = await collectCachedTitles(options.source);
      const result = evaluateCorpusAst(query, corpus, options);
      if (options.print !== false) {
      printAstProbe(result, options.limit);
      }
      return result;
      }