Logo IconGuided Mind
v2.4Sign In
Python SDK

RAG Search

Query your indexed documents with semantic, keyword, hybrid, or graph-based search.

client.search() is the core method of the SDK. It queries your project's document index and returns ranked results with relevance scores.

from guidedmind import Client
 
client = Client()
 
response = client.search(query="What are the main features?")
 
print(f"Found {len(response.results)} results")
for result in response.results:
    print(f"  {result.score:.3f}  {result.content[:120]}...")

Advanced Options

from guidedmind import Client, SearchMethod
 
response = client.search(
    query="Explain the microservices architecture",
    limit=10,
    threshold=0.75,
    search_method=SearchMethod.HYBRID,
    include_metadata=True,
)
 
print(f"Method used : {response.metadata.search_method_used}")
print(f"Processing  : {response.metadata.processing_time_ms}ms")
 
for result in response.results:
    print(f"  [{result.score:.3f}] {result.content[:80]}")
    if result.metadata:
        print(f"           source: {result.metadata.get('source')}")

Search Parameters

ParameterTypeDefaultDescription
queryrequiredstrNatural language search query.
limitint5Maximum number of results to return.
thresholdfloat0.70Minimum relevance score (0–1). Results below this are excluded.
search_methodSearchMethodHYBRIDAlgorithm to use. See table below.
include_metadataboolFalseWhen true, each result includes source metadata (file name, chunk index, custom fields).

Search Methods

MethodDescriptionBest For
SearchMethod.DENSEVector-based semantic similarity (cosine distance)Conceptual questions, natural language
SearchMethod.SPARSEKeyword BM25 rankingExact terms, product names, codes
SearchMethod.HYBRIDWeighted combination of dense + sparseMost production workloads — start here
SearchMethod.GRAPHKnowledge graph traversal for multi-hop reasoningEntity relationships, complex inference

Start with SearchMethod.HYBRID. It consistently outperforms single-method search across diverse query types without any additional cost. Switch to DENSE or SPARSE only after profiling your specific query distribution.

Response Shape

response.results          # List[SearchResult]
response.metadata         # SearchMetadata
 
# SearchResult fields
result.content            # str  — the matching chunk text
result.score              # float — relevance score (0–1)
result.document_id        # str  — source document ID
result.chunk_index        # int  — position within the document
result.metadata           # dict — custom metadata (when include_metadata=True)
 
# SearchMetadata fields
response.metadata.search_method_used   # str
response.metadata.processing_time_ms  # int
response.metadata.total_results        # int  — total matching chunks before limit

Async Version

async def search_docs(query: str):
    async with Client() as client:
        response = await client.asearch(
            query=query,
            limit=10,
            search_method=SearchMethod.HYBRID,
        )
    return response.results