iQ Suite - Docs

Search

Perform a search query on a specific index.

Description

The Search endpoint allows you to perform a search query on a specific index to retrieve relevant documents based on the search criteria.

HTTP Request

POST /index/search

Authentication

All requests must include an Authorization header with a valid API key.

Headers

KeyValue
AuthorizationBearer YOUR_API_KEY
Content-Typeapplication/json

Request Body

  • index: The ID of the index to search.
  • query: The search query string.

JSON

FieldTypeDescription
indexstringThe ID of the index to search
querystringThe search query string

Request Example

from iqsuite import IQSuiteClient, AuthenticationError, APIError
 
client = IQSuiteClient(api_key="YOUR_API_KEY")
index_id = "index_1"
query = "Latest updates on AI research."
 
try:
    response = client.search(index_id, query)
    print(response)
except AuthenticationError:
    print("Invalid API key")
except APIError as e:
    print(f"API Error: {e}")

Response

Success

Status Code: 200 OK

Body:

{
  "results": [
    {
      "document_id": "doc_3",
      "title": "AI Research 2023",
      "snippet": "In 2023, AI research has focused on...",
      "relevance_score": 0.98
    },
    {
      "document_id": "doc_4",
      "title": "Advancements in Machine Learning",
      "snippet": "Recent advancements in machine learning include...",
      "relevance_score": 0.95
    }
  ]
}

On this page