Skip to main content
Version: 0.13.0

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:

  1. Initial search returns top-N candidates
  2. The reranker sends each candidate (with its content and metadata) to an LLM inference provider
  3. The LLM scores each result for relevance to the original query
  4. 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:

ParameterRequiredDefaultDescription
model_idYesThe inference model that scores relevance.
providerYesInference provider (bedrock or http).
content_fieldNotextThe hit field whose text is sent to the model.
image_fieldNoThe hit field containing image data, for multimodal reranking.
top_nNo10How many top candidates to rerank.
provider_configNoProvider 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.

ParameterRequiredDefaultDescription
model_idYesThe embedding model.
providerYesEmbedding provider (bedrock, openai, http, vertex, azure, azure_vision).
dimensionsNo1536Embedding width — must match the target knn_vector field.
modeNotemplatetemplate substitutes the vector into query_template at ${embedding}; path writes it into an existing query at embedding_path.
query_templateIn template modeThe search body containing the ${embedding} placeholder.
embedding_pathIn path modeJSON path in the request query to write the vector to.
on_failure_actionNofailfail (reject the search) or passthrough (run the query without embedding).
provider_configNoProvider 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:

ParameterRequiredDefaultDescription
target_fieldNo_groundingThe hit field the grounding object is written to.
include_provenanceNotrueAdd source provenance (parent document URI, page number, title).
include_spatial_contextNotrueAdd geographic context (bbox, CRS) for geospatial hits.
include_chunk_contextNotrueAdd chunk position and surrounding (preceding/following) text.
context_snippet_charsNo200Characters of surrounding text to include per side.
generate_preview_urlsNofalseGenerate presigned preview URLs for image/tile hits.
preview_uri_fieldNotile_uriThe hit field holding the object URI to presign.
preview_expiry_secondsNo3600Presigned-URL lifetime.
reference_configNoObject-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.