Search Documents

Search Documents

This method allows you to search for documents in an index that are relevant to a particular search input.

The request allows you specify a particular text which is then embedded using the index configuration. The API will search through all indexed documents and find chunks that match the content of text. More specifically, the API will find any chunk with a small vector-distance between the embedded text and the embedded document chunk content.

The document chunks that are most closely related to the provided text are returned in the response, and the API will return up to top_k chunks. Additionally, you can further limit which chunks are returned by specifying a via similarity_cutoff, which means that only chunks that meet a minimum similarity are included in the response.

The response includes, for each chunk that was found, metadata about the document from which the chunk was extracted. This provides a link back to the document that was added to the index.

Request
URI
POST
https://{api_host}/api/v1/control/knowledge-bases/{knowledge_base_id}/indexes/{index_id}/search
COPY
Path Parameters
string
knowledge_base_id
Required

knowledge_base_id

string
index_id
Required

index_id


Request Body
IndexEmbeddingsSearchParams of type(s) application/json
Required

Show optional properties

{
    "text": "string"
}
{
    "text": "string",
    "top_k": 0,
    "similarity_cutoff": "number"
}
string
text
Required

Search text string.

integer
top_k
Optional
Constraints: default: 2

Return only the k top answers.

number
similarity_cutoff
Optional

Return only answers within this similarity.

Authentication
This operation uses the following authentication methods.
Responses
200

Successful Response

Returns DocumentChunksRetrievalResponseList of type(s) application/json
"DocumentChunksRetrievalResponseList Object"
array of object
chunks
Required

List of relevant text chunks and associated metadata from embeddings query.


404

Invalid knowledge base or index ID.

Operation doesn't return any data structure

422

Validation Error

Returns HTTPValidationError of type(s) application/json
"HTTPValidationError Object"
array of object
detail
Optional

detail


Code Samples
COPY
                    curl -X POST -H 'Authorization: <value>' -H 'Content-Type: application/json' -d '{"text:"string"}' https://{api_host}/api/v1/control/knowledge-bases/{knowledge_base_id}/indexes/{index_id}/search