Skip to content

Search Result Summaries

This reference covers the AI-related search endpoints available on a Searchcraft index.

  • GET /index/:index/capabilities Returns AI capability flags for an index.
  • POST /index/:index/search/summary Streams an AI-generated summary of search results using server-sent events.

Use the capabilities endpoint to determine whether an index has AI enabled and whether summary generation is configured.

The enabled flag reflects the index’s stored ai_enabled master switch. An index may still report searchSummaryConfigured: true while enabled: false if AI configuration has been saved but the master switch is currently turned off.

Authenticated requests to this endpoint require the READ permission.

Terminal window
curl -H "Authorization: read-key-value" https://searchcraft-cluster-url/index/data_test/capabilities
{
"status": 200,
"data": {
"ai": {
"enabled": true,
"searchSummaryConfigured": true,
"llmProviderConfigured": true,
"llmModelConfigured": true
}
}
}

The summary endpoint accepts the same request body shape as POST /index/:index/search. The payload is a standard Searchcraft query payload.

Authenticated requests to this endpoint require the LLM_RAG_SUMMARIES permission.

Summary responses are streamed as text/event-stream; charset=utf-8.

The endpoint returns 400 in the following situations. Use GET /index/:index/capabilities to check availability before calling the summary endpoint. See Optional AI configuration for how to configure these settings.

ConditionMessage
ai_enabled is falseAI features are disabled for this index
No ai block configuredAI features not configured for this index
ai exists but no search_summary blockSearch summary not configured for this index
Invalid llm_provider valueInvalid LLM provider
Terminal window
curl -N -H "Content-Type: application/json" -H "Authorization: read-key-value" --data '{"query":"wireless headphones","limit":5}' https://searchcraft-cluster-url/index/data_test/search/summary
event: metadata
data: {"results_count":3,"cached":false}
event: delta
data: {"content":"Top options include..."}
event: done
data: {"results_count":3}
EventPayloadDescription
metadata{"results_count": number, "cached": boolean}Always the first event. results_count is the number of search hits found. cached is true when both the search results and the generated summary were served from cache.
delta{"content": string}One or more delta events containing the streamed summary text. When there are zero results, a single delta is emitted with the configured empty_state_message instead of calling the LLM.
done{"results_count": number}Final event indicating the stream has completed.
error{"message": string}Emitted if a streaming error occurs.

When a search query returns no hits, the LLM is not called. Instead, the endpoint immediately emits a delta event containing the empty_state_message configured on the index, with the ${searchTopic} placeholder substituted for the matched search term. If a matching keyword rule provides its own empty_state_message, that takes precedence over the index-level default.

The summary endpoint supports the same structured queries as the standard search endpoint.

Terminal window
curl -N -H "Content-Type: application/json" -H "Authorization: read-key-value" --data '{"query":[{"dynamic":{"ctx":"gaming laptop"}},{"term":{"ctx":"Asus","fields":"brand"}}],"limit":5}' https://searchcraft-cluster-url/index/data_test/search/summary

When keyword rules are configured, Searchcraft derives human-readable match text from supported query fragments including fuzzy, exact, dynamic queries.

Keyword rules are configured on the index declaration under ai.search_summary.keyword_rules. See Optional AI configuration for the full rule schema.

Rules are sorted by order and evaluated in that order. The first matching rule wins and no further rules are evaluated.

A rule matches when any keyword in its detect_keywords array is found in the search term. Matching is case-insensitive and substring-based, so a keyword of "nutrition" would also match a query like "malnutrition".

FieldDescription
replacement_termWhen set, replaces the search term submitted to the search engine and used as the topic in the LLM prompt. The original search term is preserved only for display purposes.
custom_instructionAppended to the index-level additional_prompt_instructions when the rule matches.
empty_state_messageOverrides the index-level empty_state_message when the rule matches and the search returns no results. Supports ${searchTopic} placeholder replacement.

The summary endpoint works with any LLM provider configured on the index. Supported providers are:

Providerllm_provider valueCredential
AWS BedrockbedrockAWS SDK credential chain (llm_region required)
llama.cppllamacppNone (llm_base_url required)
OllamaollamaNone
OpenAIopenaillm_api_key
Anthropicanthropicllm_api_key
Google Geminigooglellm_api_key
xAI (Grok)xaillm_api_key
Mistral AImistralllm_api_key

See Optional AI configuration for full configuration examples and field descriptions.