• Search for nodes similar to a query (high-level convenience function)

    This combines embedding generation, vector search, and node retrieval into a single function call. Use this when you need the raw search results with nodes but don't need formatted context. For LLM-ready context, use getContextForQuery instead.

    Parameters

    • db: Surreal

      SurrealDB instance

    • query: string

      Natural language query text (e.g., "authentication functions")

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

      Search options:

      • limit: Number of results to return (default: 5)
      • effort: HNSW search effort parameter (default: 40)

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

    Array of similarity results, each containing:

    • id: embedding_cache record ID
    • contentHash: Hash for matching to nodes
    • dist: Distance score (lower = more similar)
    • node: Full node data (if matched)
    const results = await searchBySimilarity(db, "user authentication", { limit: 10 });
    for (const result of results) {
    console.log(`${result.node?.name} (distance: ${result.dist})`);
    }