Reranking and retrieval grounding
After initial retrieval, Lucenia's search pipeline processors can rerank results using LLM-powered analysis and enrich them with provenance information for RAG citation. These processors transform raw search hits into grounded, citation-ready results.
Multimodal reranking
The multimodal rerank response processor uses LLM inference to rerank the top-N search results based on deep understanding of both the query and result content. Unlike score-based reranking, it can reason about relevance across text, images, and structured data.
How it works:
- Initial search returns top-N candidates
- The reranker sends each candidate (with its content and metadata) to an LLM inference provider
- The LLM scores each result for relevance to the original query
- Results are reordered by the LLM relevance score
This is especially powerful for multimodal content where a text query needs to match against images, charts, or mixed-content documents.
multimodal_rerank parameters:
| Parameter | Required | Default | Description |
|---|---|---|---|
model_id | Yes | — | The inference model that scores relevance. |
provider | Yes | — | Inference provider (bedrock or http). |
content_field | No | text | The hit field whose text is sent to the model. |
image_field | No | — | The hit field containing image data, for multimodal reranking. |
top_n | No | 10 | How many top candidates to rerank. |
provider_config | No | — | Provider settings (for example { "region": "us-east-1" }). |
Query embedding
The query_embedding request processor turns a plain-text query into a vector so the search can run k-NN/hybrid retrieval without the client computing embeddings.
| Parameter | Required | Default | Description |
|---|---|---|---|
model_id | Yes | — | The embedding model. |
provider | Yes | — | Embedding provider (bedrock, openai, http, vertex, azure, azure_vision). |
dimensions | No | 1536 | Embedding width — must match the target knn_vector field. |
mode | No | template | template substitutes the vector into query_template at ${embedding}; path writes it into an existing query at embedding_path. |
query_template | In template mode | — | The search body containing the ${embedding} placeholder. |
embedding_path | In path mode | — | JSON path in the request query to write the vector to. |
on_failure_action | No | fail | fail (reject the search) or passthrough (run the query without embedding). |
provider_config | No | — | Provider settings. |
Retrieval grounding
The retrieval grounding response processor enriches search results with provenance and context information needed for reliable RAG applications. Each hit is annotated with:
- Source provenance: Which document and section the result came from
- Spatial context: Geographic coordinates and bounding boxes for geospatial content
- Chunk context: Surrounding text and position within the original document
- Confidence metadata: Extraction confidence and relevance signals
This enables downstream LLM applications to generate answers with proper citations, linking back to the exact source material.
retrieval_grounding parameters:
| Parameter | Required | Default | Description |
|---|---|---|---|
target_field | No | _grounding | The hit field the grounding object is written to. |
include_provenance | No | true | Add source provenance (parent document URI, page number, title). |
include_spatial_context | No | true | Add geographic context (bbox, CRS) for geospatial hits. |
include_chunk_context | No | true | Add chunk position and surrounding (preceding/following) text. |
context_snippet_chars | No | 200 | Characters of surrounding text to include per side. |
generate_preview_urls | No | false | Generate presigned preview URLs for image/tile hits. |
preview_uri_field | No | tile_uri | The hit field holding the object URI to presign. |
preview_expiry_seconds | No | 3600 | Presigned-URL lifetime. |
reference_config | No | — | Object-store settings used to presign preview URLs. |
Each hit's _grounding object carries source_provenance (parent URI, page, title), spatial_context (bbox, CRS — georeferenced hits only), chunk_context (position, total chunks, preceding/following text), and, when enabled, a preview_url.
End-to-end search pipeline
Combine query embedding, reranking, and grounding in a single search pipeline:
PUT _search/pipeline/ai-retrieval-pipeline
{
"request_processors": [
{
"query_embedding": {
"model_id": "amazon.titan-embed-text-v2:0",
"provider": "bedrock",
"dimensions": 1024,
"mode": "template",
"query_template": {
"size": 20,
"query": { "knn": { "chunks.embedding": { "vector": ${embedding}, "k": 20 } } }
},
"provider_config": { "region": "us-east-1" }
}
}
],
"response_processors": [
{
"multimodal_rerank": {
"provider": "bedrock",
"model_id": "anthropic.claude-sonnet-4-20250514",
"content_field": "chunks.text",
"top_n": 10
}
},
{
"retrieval_grounding": {
"target_field": "_grounding",
"include_provenance": true,
"include_spatial_context": true,
"include_chunk_context": true
}
}
]
}
The query_embedding request processor embeds the caller's query text and substitutes the resulting vector into the ${embedding} placeholder in query_template (template mode), or into an existing query at embedding_path (path mode).
The flow:
User query: "How does Lucenia handle coordinate reprojection?"
│
▼
┌─────────────────────┐
│ Query embedding │ Convert text query to vector
│ (request proc.) │
└──────────┬──────────┘
▼
┌─────────────────────┐
│ k-NN + BM25 search │ Retrieve top candidates
└──────────┬──────────┘
▼
┌─────────────────────┐
│ Multimodal rerank │ LLM re-scores for relevance
│ (response proc.) │
└──────────┬──────────┘
▼
┌─────────────────────┐
│ Retrieval grounding│ Add citations and provenance
│ (response proc.) │
└──────────┬──────────┘
▼
Grounded results with citations
The result is a search pipeline that takes a plain text question, automatically embeds it, retrieves the most relevant content, reranks using LLM reasoning, and returns results annotated with everything an AI application needs to generate cited answers.