search

View as MarkdownOpen in Claude

Perform a semantic search across all documents in the Datasphere.

Request

query_stringstringRequired
Search term.
tagslist of stringsOptional
Document tags.
document_idstringOptionalformat: "uuid"
Unique ID of a Document.
distancedoubleOptional0-78.3836717690617
Specifies how closely related the query is to the document. Low distance means high relevance and similarity. High distance means low relevance and similarity.
countintegerOptional>=1Defaults to 5
Specifies number of returned Chunks.
languagestringOptionalDefaults to en
Language of the Document.
pos_to_expandlist of stringsOptionalDefaults to ["NOUN","VERB","ADJ","ADV"]
Part of Speech considered for expansion or analysis.
max_synonymsintegerOptional>=1Defaults to 10
Maximum number of synonyms to consider.

Response

chunkslist of objectsRequired
A list of search result chunks.

Response Example

Response
{
"chunks": [
{
"text": "Cristiano Ronaldo is the highest-paid football player in the world in 2024",
"document_id": "acaa5c49-be5e-4477-bce0-48f4b23b7720"
}
]
}

Example

import { RestClient } from "@signalwire/sdk";
const client = new RestClient({
project: "your-project-id",
token: "your-api-token",
host: "your-space.signalwire.com"
});
const results = await client.datasphere.documents.search({
query_string: "How do I reset my password?",
count: 5,
});
for (const chunk of results.data ?? []) {
console.log(chunk.text, "score:", chunk.score);
}