SearchEngine (src/search.ts)

Understand-Anything · understand-anything-plugin/packages/core/src/search.ts · typescript · MIT
search, tag:knn-classified

Module exposing: SearchEngine

// Source: https://github.com/Egonex-AI/Understand-Anything | License: MIT | Copyright 2026 Yuxiang Lin
// Provided via justclaw.it.com; keep this notice with the code.
import Fuse, { type IFuseOptions } from "fuse.js";
import type { GraphNode } from "./types.js";

export interface SearchResult {
  nodeId: string;
  score: number; // 0 = perfect match, 1 = worst match
}

export interface SearchOptions {
  types?: GraphNode["type"][];
  limit?: number;
}

const FUSE_OPTIONS: IFuseOptions<GraphNode> = {
  keys: [
    { name: "name", weight: 0.4 },
    { name: "tags", weight: 0.3 },
    { name: "summary", weight: 0.2 },
    { name: "languageNotes", weight: 0.1 },
  ],
  threshold: 0.4,
  includeScore: true,
  ignoreLocation: true,
  useExtendedSearch: true,
};

export class SearchEngine {
  p

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key