Overview
The search strategy advisor analyzes a query and recommends the best search mode to use. This is useful when you are unsure whether to use semantic, fulltext, aggregate, or deep search for a given query.
Use this endpoint to let Trix choose the optimal search strategy automatically, or to educate users about which strategy works best for their query type.
Available Strategies
- semantic — best for conceptual or natural language queries (e.g., "how to handle errors gracefully")
- fulltext — best for exact keywords, names, or technical terms (e.g., "ECONNREFUSED port 5432")
- hybrid — combines semantic + fulltext with score fusion; the safe default when you need both precision and recall
API Endpoint
Request
POST /v1/search/suggest-strategy
{
"query": "how to handle database connection timeouts"
}SDK Examples
import { Trix } from '@trixdb/client';
const trix = new Trix({ apiKey: process.env.TRIX_API_KEY });
const suggestion = await trix.search.suggestStrategy({
query: 'how to handle database connection timeouts',
});
console.log(`Recommended: ${suggestion.strategy}`);
console.log(`Confidence: ${suggestion.confidence}`);
console.log(`Reason: ${suggestion.reason}`);
// Use the suggested strategy for the actual search
const results = await trix.memories.list({
q: 'how to handle database connection timeouts',
mode: suggestion.strategy,
});Response Fields
- strategy — the recommended search mode
- confidence — how confident the recommendation is
(
high,medium,low) - reason — a human-readable explanation of why this strategy was chosen