• Preparing search index...
  • The search index is not available
Tidyscripts Docs
  • Tidyscripts Docs
  • node
  • generic_hierarchical_embedder
  • query
  • searchBySimilarity

Function searchBySimilarity

  • searchBySimilarity(query, options?): Promise<node.generic_hierarchical_embedder.query.SimilarityResult[]>
  • Search for chunks similar to a query using vector similarity

    Uses SurrealDB's built-in vector search with KNN operator for efficiency.

    Process:

    1. Generate embedding for the query
    2. Use SurrealDB's <|limit,COSINE|> operator to find nearest neighbors
    3. Join with chunk table to get chunk content and metadata
    4. Filter by threshold and optional filters (project, file extension)
    5. Enrich with file metadata

    Parameters

    • query: string

      Natural language query string

    • options: node.generic_hierarchical_embedder.query.SimilaritySearchOptions = {}

      Search options (limit, threshold, filters)

    Returns Promise<node.generic_hierarchical_embedder.query.SimilarityResult[]>

    Array of similarity results sorted by relevance

    Example

    const results = await searchBySimilarity(
    "function that validates user input",
    { limit: 5, threshold: 0.3, projectId: "project:abc123" }
    );
    • Defined in packages/ts_node/src/generic_hierarchical_embedder/query.ts:146

Settings

Member Visibility
Tidyscripts Docs
  • Loading...

Generated using TypeDoc