Skip to main content

Overview

Moorcheh’s Search API allows you to perform advanced semantic searches across one or multiple namespaces using text queries or vector embeddings. The API uses ITS (Information Theoretic Similarity) scoring to provide highly accurate relevance rankings.
The Search API supports both text and vector namespaces, with automatic embedding generation for text queries and advanced binarization techniques for optimal performance.

Search Types

from moorcheh_sdk import MoorchehClient

client = MoorchehClient(api_key="your-api-key")

# Perform search
results = client.search(
    namespaces=["my-documents"],
    query="What is Moorcheh?",
    top_k=5
)

# Display results
for match in results["matches"]:
    print(f"ID: {match['id']}")
    print(f"Score: {match['score']}")
    print(f"Text: {match.get('text', 'N/A')}")

Search Parameters

ParameterTypeRequiredDescription
namespacesarrayYesArray of namespace names to search
querystring or arrayYesText query or vector array
top_knumberNoNumber of results (default: 10)
thresholdnumberNoMinimum score threshold (0-1)
kiosk_modebooleanNoEnable strict filtering

Metadata Filtering

Filter search results using metadata fields for highly targeted results.

Syntax

  • Metadata filters: #key:value
  • Keyword filters: #keyword

Examples

# Search with metadata filter
results = client.search(
    namespaces=["my-documents"],
    query="technical documentation #category:api",
    top_k=5
)

# Multiple filters
results = client.search(
    namespaces=["my-documents"],
    query="payment processing #category:financial #priority:high",
    top_k=5
)

# Keyword filters
results = client.search(
    namespaces=["my-documents"],
    query="deployment guide #important #urgent",
    top_k=5
)
Filters only apply to text search and metadata must be included when uploading documents.
Search across multiple namespaces simultaneously:
# Search multiple namespaces
results = client.search(
    namespaces=["docs", "blog-posts", "support-tickets"],
    query="How to integrate the API?",
    top_k=10
)

Kiosk Mode

Enable kiosk mode for production environments with strict filtering:
# Search with kiosk mode
results = client.search(
    namespaces=["my-documents"],
    query="product features",
    kiosk_mode=True,
    threshold=0.7,  # Required when kiosk_mode is True
    top_k=5
)
Kiosk Mode Benefits:
  • Filters results below threshold
  • More controlled results
  • Better for production environments

Response Format

{
  "matches": [
    {
      "id": "doc-123",
      "score": 0.95,
      "text": "Document content...",
      "metadata": {
        "category": "api",
        "source": "documentation"
      }
    }
  ],
  "total": 1
}

Best Practices

Optimize top_k

Use lower values (3-5) for focused results, higher values (10-20) for broader exploration

Use Metadata Filters

Combine semantic search with metadata for precise targeting

Set Thresholds

Use threshold parameter to filter low-relevance results

Multi-Namespace Search

Search across related namespaces for comprehensive results

Next Steps