Search for Vector Store documents by semantic similarity

Search Vector Store documents with semantic similarity and batch operations

Initiate a search operation with a query text and receive most semantically similar responses from the vector store.

Path parameters
vector-store-idstringRequired

The ID of the vector store.

Query parameters
qstringRequired

The search query text.

nintegerOptional

Number of chunks to return.

tnumberOptional

Matching threshold.

prev_chunksintegerOptional

Number of chunks before the matched chunk to include.

next_chunksintegerOptional

Number of chunks after the matched chunk to include.

Header parameters
x-api-keystringRequired

The API key for authentication.

Responses
200
Search results retrieved successfully.
application/json
get
GET /api/v1/vector-stores/{vector-store-id}/documents/search HTTP/1.1
Host: api.rememberizer.ai
x-api-key: text
Accept: */*
200

Search results retrieved successfully.

{
  "vector_store": {
    "id": "text",
    "name": "text"
  },
  "matched_chunks": [
    {
      "document": {
        "id": 1,
        "name": "text",
        "type": "text",
        "size": 1,
        "indexed_on": "2025-06-30T20:32:33.133Z",
        "vector_store": "text",
        "created": "2025-06-30T20:32:33.133Z",
        "modified": "2025-06-30T20:32:33.133Z"
      },
      "matched_content": "text",
      "distance": 1
    }
  ]
}

Example Requests

curl -X GET \
  "https://api.rememberizer.ai/api/v1/vector-stores/vs_abc123/documents/search?q=How%20to%20integrate%20our%20product%20with%20third-party%20systems&n=5&prev_chunks=1&next_chunks=1" \
  -H "x-api-key: YOUR_API_KEY"

Replace YOUR_API_KEY with your actual Vector Store API key and vs_abc123 with your Vector Store ID.

Path Parameters

Parameter
Type
Description

vector-store-id

string

Required. The ID of the vector store to search in.

Query Parameters

Parameter
Type
Description

q

string

Required. The search query text.

n

integer

Number of results to return. Default: 10.

t

number

Matching threshold. Default: 0.7.

prev_chunks

integer

Number of chunks before the matched chunk to include. Default: 0.

next_chunks

integer

Number of chunks after the matched chunk to include. Default: 0.

Response Format

{
  "vector_store": {
    "id": "vs_abc123",
    "name": "Product Documentation"
  },
  "matched_chunks": [
    {
      "document": {
        "id": 1234,
        "name": "Integration Guide.pdf",
        "type": "application/pdf",
        "size": 250000,
        "indexed_on": "2023-06-15T10:30:00Z",
        "vector_store": "vs_abc123",
        "created": "2023-06-15T10:15:00Z",
        "modified": "2023-06-15T10:30:00Z"
      },
      "matched_content": "Our product offers several integration options for third-party systems. The primary method is through our RESTful API, which supports OAuth2 authentication. Additionally, you can use our SDK available in Python, JavaScript, and Java.",
      "distance": 0.123
    },
    // ... more matched chunks
  ]
}

Authentication

This endpoint requires authentication using an API key in the x-api-key header.

Error Responses

Status Code
Description

400

Bad Request - Missing required parameters or invalid format

401

Unauthorized - Invalid or missing API key

404

Not Found - Vector Store not found

500

Internal Server Error

Search Optimization Tips

Context Windows

Use the prev_chunks and next_chunks parameters to control how much context is included with each match:

  • Set both to 0 for precise matches without context

  • Set both to 1-2 for matches with minimal context

  • Set both to 3-5 for matches with substantial context

Matching Threshold

The t parameter controls how strictly matches are filtered:

  • Higher values (e.g., 0.9) return only very close matches

  • Lower values (e.g., 0.5) return more matches with greater variety

  • The default (0.7) provides a balanced approach

Batch Operations

For high-throughput applications, Rememberizer supports efficient batch operations on vector stores. These methods optimize performance when processing multiple search queries.

Batch Search Implementation

import requests
import time
import concurrent.futures

def batch_search_vector_store(vector_store_id, queries, num_results=5, batch_size=10):
    """
    Perform batch searches against a vector store
    
    Args:
        vector_store_id: ID of the vector store to search
        queries: List of search query strings
        num_results: Number of results per query
        batch_size: Number of parallel requests
        
    Returns:
        List of search results
    """
    headers = {
        "x-api-key": "YOUR_API_KEY"
    }
    
    results = []
    
    # Process in batches to avoid overwhelming the API
    for i in range(0, len(queries), batch_size):
        batch_queries = queries[i:i+batch_size]
        
        with concurrent.futures.ThreadPoolExecutor(max_workers=batch_size) as executor:
            futures = []
            
            for query in batch_queries:
                params = {
                    "q": query,
                    "n": num_results,
                    "prev_chunks": 1,
                    "next_chunks": 1
                }
                
                # Submit the request to the thread pool
                future = executor.submit(
                    requests.get,
                    f"https://api.rememberizer.ai/api/v1/vector-stores/{vector_store_id}/documents/search",
                    headers=headers,
                    params=params
                )
                futures.append(future)
            
            # Collect results from all futures
            for future in futures:
                response = future.result()
                if response.status_code == 200:
                    results.append(response.json())
                else:
                    results.append({"error": f"Failed with status code: {response.status_code}"})
        
        # Add a delay between batches to avoid rate limiting
        if i + batch_size < len(queries):
            time.sleep(1)
    
    return results

# Example usage
queries = [
    "Integration with REST APIs",
    "Authentication protocols",
    "How to deploy to production",
    "Performance optimization techniques",
    "Error handling best practices"
]

search_results = batch_search_vector_store("vs_abc123", queries, num_results=3, batch_size=5)

Performance Optimization for Batch Operations

When implementing batch operations for vector store searches, consider these best practices:

  1. Optimal Batch Sizing: For most applications, processing 5-10 queries in parallel provides a good balance between throughput and resource usage.

  2. Rate Limiting Awareness: Include delay mechanisms between batches (typically 1-2 seconds) to avoid hitting API rate limits.

  3. Error Handling: Implement robust error handling for individual queries that may fail within a batch.

  4. Connection Management: For high-volume applications, implement connection pooling to reduce overhead.

  5. Timeout Configuration: Set appropriate timeouts for each request to prevent long-running queries from blocking the entire batch.

  6. Result Processing: Consider processing results asynchronously as they become available rather than waiting for all results.

  7. Monitoring: Track performance metrics like average response time and success rates to identify optimization opportunities.

For production applications with very high query volumes, consider implementing a queue system with worker processes to manage large batches efficiently.

This endpoint allows you to search your vector store using semantic similarity. It returns documents that are conceptually related to your query, even if they don't contain the exact keywords. This makes it particularly powerful for natural language queries and question answering.

Last updated