search_direct

View as MarkdownOpen in Claude

Perform a search programmatically without going through the HTTP API. This is useful for embedding search in application code where you want the full preprocessing pipeline but do not need network overhead.

Parameters

query
strRequired

The search query text.

index_name
strDefaults to default

Name of the index to search.

count
intDefaults to 3

Maximum number of results to return.

distance
floatDefaults to 0.0

Minimum similarity threshold for results.

tags
list[str] | NoneDefaults to None

Filter results by tags.

language
str | NoneDefaults to None

Language code for query processing, or None for auto-detection.

Returns

dict[str, Any] — A dictionary with:

  • results (list) — list of result dicts, each with content, score, and metadata
  • query_analysis (dict) — information about query preprocessing

Example

from signalwire.search import SearchService
service = SearchService(indexes={"docs": "./docs.swsearch"})
response = service.search_direct(
query="How do I set up an agent?",
index_name="docs",
count=5,
)
for result in response["results"]:
print(f"[{result['score']:.3f}] {result['content'][:100]}")