Spotlight query

August 2, 2026 · View on GitHub

Glyph Spotlight

Spotlight query

Rank chunks, then filter by threshold and limit.

Primary use case: feature extraction — probe with example glyphs (emails, URLs, etc.) and keep chunks that clear a threshold.

import { CreateGroup, spotlight } from "@koda.oss/glyph";

const doc = spotlight.New(longArticleText);

const hits = doc.Query(
  CreateGroup(["user@example.com", "https://example.com/path"]),
  { threshold: 0.2, limit: 10 },
);

for (const hit of hits) {
  console.log(hit.score, hit.text);
}

Options

OptionDefaultEffect
threshold0Drop results with score < threshold
limitomittedKeep at most N results after sort
textOutputfalseReturn string[] instead of GlyphSpotlightResult[]
aggregatesumGroup probe aggregate
chunker / createOnly apply at spotlight.New (ignored if passed only to Query)

Compile-time options (chunker, create, normalize) belong on spotlight.New. Query-time options are threshold, limit, textOutput, and aggregate.

textOutput

const snippets = doc.Query(probe, {
  threshold: 0.15,
  limit: 5,
  textOutput: true,
});

Related links ranked by Glyph.