Skip to main content

Search API

The Search API provides powerful memory retrieval capabilities including semantic search, advanced filtering, and proprietary spreading activation technology for multi-hop reasoning. All search operations are optimized for performance and relevance.

Authentication

All search endpoints require authentication with API key:

Rate Limits

Semantic Search (GET)

Perform semantic search with query parameters. Endpoint: GET /search Query Parameters:
  • q (string, required): Search query
  • user_id (string): Filter by user ID
  • category (string): Filter by memory category
  • type (string): Filter by memory type
  • limit (integer, default: 10, max: 50): Number of results
  • offset (integer, default: 0): Offset for pagination
  • threshold (float, default: 0.7): Similarity threshold (0.0-1.0)
  • include_content (boolean, default: true): Include memory content
  • include_metadata (boolean, default: true): Include metadata
Response:
Example:

Semantic Search (POST)

Perform semantic search with complex filters and options. Endpoint: POST /search Request Body:
Parameters:
  • query (string, required): Search query
  • filters (object): Filter criteria
    • user_id (string or array): User ID(s)
    • category (string or array): Memory category(ies)
    • type (string or array): Memory type(s)
    • created_after (string): Timestamp filter
    • created_before (string): Timestamp filter
    • metadata (object): Metadata key-value pairs
  • options (object): Search options
    • limit (integer): Results per page
    • offset (integer): Pagination offset
    • threshold (float): Similarity threshold
    • include_content (boolean): Include content
    • include_metadata (boolean): Include metadata
    • sort (string): Sort field (“score”, “created_at”, “updated_at”)
    • order (string): Sort order (“asc”, “desc”)
Response:
Example:

Advanced Search

Perform complex searches with multiple filters and ranking options. Endpoint: POST /search/advanced Request Body:
Parameters:
  • query (string, required): Search query
  • filters (object): Complex filter criteria
  • ranking (object): Ranking configuration
    • sort_by (string): Primary sort field
    • order (string): Sort direction
    • boost_fields (object): Field boost factors
  • aggregation (object): Aggregation options
    • by_category (boolean): Group by category
    • by_user (boolean): Group by user
    • by_date (object): Date aggregation settings
Response:
Combine semantic search with keyword search for better results. Endpoint: POST /search/hybrid Request Body:
Parameters:
  • query (string, required): Search query
  • semantic_weight (float, default: 0.8): Weight for semantic search
  • keyword_weight (float, default: 0.2): Weight for keyword search
  • filters (object): Filter criteria
  • options (object): Search options
Response:

Enhanced Search with Spreading Activation

Use proprietary spreading activation technology for multi-hop reasoning. Endpoint: GET /search/enhanced Query Parameters:
  • q (string, required): Search query
  • mode (string, default: “spreading”, options: “spreading”, “semantic”, “hybrid”): Search mode
  • max_hops (integer, default: 3, max: 5): Maximum propagation hops
  • decay_factor (float, default: 0.85): Activation decay per hop
  • threshold (float, default: 0.1): Activation threshold
  • budget (float, default: 1.0): Initial activation budget
  • include_path (boolean, default: false): Include activation paths
Request Body (POST):
Response:
Example:

Search Analytics

Get Search Statistics

Retrieve search performance and usage statistics. Endpoint: GET /search/stats Response:

Search Configuration

Get Search Configuration

Retrieve current search configuration settings. Endpoint: GET /search/config Response:

Update Search Configuration

Update search configuration (admin only). Endpoint: PUT /search/config Request Body:

Error Handling

Common Error Responses

Error Codes

Best Practices

Search Optimization

  1. Use Appropriate Thresholds: Adjust similarity threshold based on use case
  2. Filter Early: Apply filters to reduce search space
  3. Limit Results: Use reasonable limits to improve performance
  4. Batch Operations: Use batch search for multiple queries
  5. Cache Results: Cache frequent search queries

Spreading Activation Tips

  1. Tune Parameters: Adjust decay_factor and max_hops for your use case
  2. Monitor Performance: Track spreading activation performance
  3. Use Budget Wisely: Set appropriate initial budget values
  4. Include Paths: Enable include_path for debugging and analysis

Hybrid Search Strategy

  1. Balance Weights: Adjust semantic_weight and keyword_weight based on data
  2. Combine Strengths: Use semantic for meaning, keyword for exact matches
  3. Monitor Results: Track performance of each search mode
  4. Fallback Strategy: Have fallback to basic search if hybrid fails

Performance Metrics

Key Performance Indicators

  • Response Time: Target under 200ms for basic search, under 1000ms for spreading activation
  • Relevance Score: Target >0.8 average relevance
  • Precision: Target >0.9 for top results
  • Recall: Target >0.8 for important queries
  • Success Rate: Target >99.5%

Monitoring Recommendations

  1. Track Response Times: Monitor P95 response times
  2. Monitor Error Rates: Track search failures
  3. Analyze Query Patterns: Identify popular and failing queries
  4. Performance Testing: Regular load testing for search endpoints
  5. Resource Monitoring: Monitor CPU, memory, and network usage