Skip to content

Search & Filtering

Send a natural language query and get ranked results:

Terminal window
curl -X POST https://api.useragex.com/api/v1/knowledge-bases/KB_ID/search \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "query": "How do I reset my password?", "top_k": 5 }'

Filter search results by document metadata using operator-based filters. Filters are applied after vector search, narrowing the result set to chunks from matching documents.

OperatorDescriptionExample
$eqEqual to{"status": {"$eq": "published"}}
$neNot equal to{"status": {"$ne": "draft"}}
$gtGreater than{"version": {"$gt": 1}}
$gteGreater than or equal{"version": {"$gte": 2}}
$ltLess than{"priority": {"$lt": 5}}
$lteLess than or equal{"priority": {"$lte": 3}}
$inIn array{"department": {"$in": ["eng", "ops"]}}
$ninNot in array{"department": {"$nin": ["hr"]}}

Single filter:

Terminal window
curl -X POST https://api.useragex.com/api/v1/knowledge-bases/KB_ID/search \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "authentication setup",
"filter": {
"department": { "$eq": "engineering" }
}
}'

Multiple filters (AND logic):

{
"query": "security best practices",
"filter": {
"department": { "$eq": "engineering" },
"version": { "$gte": 2 },
"language": { "$in": ["en", "es"] }
}
}

All filter conditions must match (AND). There is no OR operator at the top level.

Set a minimum relevance score to filter out low-quality matches:

{
"query": "API rate limiting",
"score_threshold": 0.5
}

Scores range from 0 to 1. A threshold of 0.5 is a reasonable starting point. Experiment with your data to find the right value.

Reranking is enabled by default. A cross-encoder model re-scores the top candidates for better accuracy.

To disable reranking (lower latency, slightly lower quality):

{
"query": "deployment instructions",
"rerank": false
}

The response tells you whether reranking was applied:

{
"usage": {
"rerank_applied": true,
"embedding_tokens": 8,
"chunks_searched": 42
}
}

If the reranker times out or errors, results are still returned with rerank_applied: false.

Use top_k to control how many results are returned (1-50, default 10):

{
"query": "onboarding process",
"top_k": 3
}

For RAG use cases, 3-5 results usually provide enough context for an LLM without excessive noise.

Upload documents with a tenant_id in metadata, then filter at query time:

{
"query": "billing FAQ",
"filter": { "tenant_id": { "$eq": "customer_123" } }
}

Only search the latest version of your docs:

{
"query": "configuration options",
"filter": { "version": { "$eq": "latest" } }
}

Restrict results to a specific language:

{
"query": "comment configurer l'authentification",
"filter": { "language": { "$eq": "fr" } }
}