Reranking OpenSearch results with cross-encoder models

A second-stage cross-encoder can reorder the top OpenSearch results for better relevance, but only if the model, its location and the latency budget are planned before the pipeline goes live.

On this page

When OpenSearch reranking with a cross-encoder improves the top results

Reranking with a cross-encoder helps when the right answer is already in your candidate set but sits too low to be seen. A team running keyword or hybrid ranking on OpenSearch often finds that the best document appears on page two, not because retrieval failed, but because the first-stage score ranks on term overlap and field weights without reading the query and document together. A second-stage model can reorder the top results using that fuller comparison. The two-stage pattern works in two steps: the first stage retrieves a candidate set quickly from the index, and the second stage rescores only the top candidates with a cross-encoder that reads the query and each document as one input. Since OpenSearch 2.12, a search pipeline with the rerank processor can reorder results using scores from a cross-encoder model.

Teams usually need reranking when users search across long, varied text where word matching is ambiguous, such as support articles, product documentation, or policy content, and when top-ten precision matters more than raw recall. It is also a fit when relevance tests show the correct answer appears in the top 50 or 100 results but not the top few. Reranking is often unnecessary when queries are short navigational lookups, when the catalog is small, when first-stage ranking already tuned with synonyms and field boosts performs well, or when the latency budget cannot absorb a model call on every query. Confirm these points with your own relevance judgments before committing to the extra stage.

Before choosing this path, measure the gap. Pull a sample of real queries, record where the relevant documents land, and check whether they fall inside the window you plan to rerank. The rerank processor works on the results it receives, so a document missing from the first-stage candidate set cannot be recovered by the model. Confirm the rerank window size, the model's maximum input length and the scores it returns against your own data, because those settings decide whether the improvement justifies the added query cost.

How a query moves through retrieval, the rerank processor and the model

A search request starts at the client and enters a search pipeline on the OpenSearch cluster, where first-stage retrieval returns candidate documents. The rerank processor then sends the query and candidate text to a cross-encoder model, either hosted in the cluster or reached through a connector to an external endpoint. Check which side of the trust boundary the model runs on, and confirm what text leaves the cluster before the reordered results return to the client.

Query flow through first-stage retrieval, the rerank processor and the model, with the trust boundary marked.

Hosting the cross-encoder in the cluster or through a connector

Hosting the cross-encoder inside the cluster means the model is loaded and executed by OpenSearch's own machine learning components, so the query text and candidate documents stay on infrastructure you operate. The rerank step becomes part of the cluster's workload, which gives you direct control over where the model runs and how it competes with indexing and search for memory and CPU.

  • Data residency: Query and document text is scored on your nodes, so no separate service needs to receive it. This usually simplifies review by security and compliance teams.
  • Network path: Scoring happens over the cluster's internal traffic, with no outbound call per query. Latency is driven by the node hardware and the number of candidates you rerank.
  • Operational ownership: Your team owns model deployment, versioning, memory sizing and node placement. Plan for model upgrades to be tested against relevance and latency targets.
  • Scaling and failure: Capacity grows by adding or resizing ML-capable nodes. If those nodes are overloaded, reranking slows or fails, so confirm how the processor behaves on error and whether you need a fallback to the original ranking.

Confirm with the OpenSearch documentation for your chosen version which model types and deployment options the rerank processor supports for in-cluster models, and check the hardware requirements before you commit to node sizes.

Rerank configuration options and when each fits

This table compares the main settings that shape a rerank search pipeline and explains when each choice fits. Read each row against your latency budget and your relevance goals, then confirm the exact parameter names and defaults for your OpenSearch version in the rerank documentation.

SettingWhat it controlsWhen it fitsCost in relevance or latency
Search pipeline definitionAttaches the rerank processor to searches that opt in, so existing queries stay unchangedUse a dedicated pipeline for the search box and leave other indices on the default pathEach pipeline change needs testing; a broken pipeline can fail searches that depend on it
Candidate count (top N)How many first-stage hits the cross-encoder scores before the final cutLarger pools suit long-tail or ambiguous queries where the right answer sits lower in BM25 orderEvery extra candidate adds model inference time, and very small pools cap what reranking can recover
Model identifierWhich cross-encoder model scores each query and document pairChoose a model matched to your language and domain, and confirm it is supported in your deployment modeLarger models usually cost more inference capacity; model swaps change scores and need a fresh relevance check
Text fields sent to the modelWhich document fields form the text the model readsSend a title and short summary for speed; add body text only when the answer lives thereMore text per document raises latency and can dilute the signal; fields with markup or boilerplate add noise
Score combination with original scoresHow model scores blend with the first-stage score in the final rankingBlend when lexical match still matters for exact product codes or names; use model scores alone for semantic queriesPure model ordering can bury exact matches; blending needs weights that must be tuned against judged queries
Timeout and fallback behaviorWhat happens when inference is slow or unavailable: return the original order or fail the requestReturn original order for user-facing search where a slow answer is worse than a less precise oneFallback hides outages from users, so monitor how often it fires; failing hard protects quality but hurts availability
Hosting path (in cluster or through connector)Where inference runs and how much capacity it uses on your cluster nodesIn-cluster hosting keeps data local; an external connector moves capacity off the search nodesConnector calls add network hops and depend on the external service; in-cluster models compete with search for resources

Budgeting latency for a second-stage model

Rerank latency grows with the number of candidates and the length of each document, so the first decision is how many hits the rerank stage scores. A cross-encoder reads the query and each candidate document together, so inference work scales roughly with the candidate count multiplied by the tokens per document. Doubling the candidates or allowing longer text fields roughly doubles model work, while the first-stage query barely changes. Set the rerank window (the number of top hits passed to the model) and a maximum field length in the search pipeline configuration, then test both limits on your own corpus. Ask any vendor or partner to show the candidate count and document length behind each number they quote, because those two inputs decide whether a benchmark is relevant to your workload.

Split the end-to-end response budget into three parts before you tune anything: first-stage search on the data nodes, model inference, and the network hops between the coordinating node, the model endpoint and the client. Measure each part separately. If the model runs in the cluster, inference shares CPU or accelerator capacity with indexing and queries, so its cost shows up as search latency under load. If it runs behind a connector, add the round trip to the external endpoint and any queueing at that endpoint. Set a timeout and a fallback so that a slow model returns the first-stage ranking instead of failing the request. Confirm the rerank processor options and timeout behavior for your OpenSearch version in the rerank cross-encoder documentation.

Measure p95 latency under production-like concurrency, not single-query timings. Build a query set from real traffic, replay it at the peak request rate you expect, and record p95 for the whole request and for each stage. Repeat the run with the rerank stage on and off so the cost of reranking is visible in isolation. No latency figures are supplied for this topic, so treat any published number as unverified until you reproduce it on your own data, hardware and model size. Record the hardware, model, candidate count, document length and batch settings with each result so the runs can be compared later. Ask your partner for the same record in the written scope, because it is the evidence you will need when you decide on candidate counts and capacity.

How to set up a rerank pipeline on OpenSearch

This sequence takes a self-hosted OpenSearch cluster from a version check to a verified second-stage reranker that reorders the top results with a cross-encoder model. Each step closes with a check, so the team knows whether to move on or roll back.

  1. Confirm the OpenSearch version supports reranking

    The platform team checks the running cluster version before any other work. The rerank search processor with cross-encoder scoring is available since OpenSearch 2.12, so a cluster older than 2.12 needs an upgrade first, and the upgrade path should be planned on its own track. Confirm the version on every node, not only on the cluster manager, because mixed versions during a rolling upgrade can hide a gap. The step is done when the version report for each node shows 2.12 or later and the team has recorded the exact version in the change record.

  2. Choose and register the cross-encoder model

    The search team selects a cross-encoder model and decides whether it runs inside the cluster or behind a connector to a model service the organization controls. The security and platform teams confirm where the model weights are stored, who can register or update them, and how outbound calls are restricted if a connector is used. Register the model through the ML Commons APIs and confirm its status reports as deployed. The check is a model status response showing the model is ready and a test scoring call returns a numeric score for a sample query and document.

  3. Create the search pipeline with the rerank processor

    Define a search pipeline that contains a rerank processor pointing at the registered model. Set the input fields the model reads, such as the document title and body, and confirm the names match the index mapping. Keep the pipeline definition in version control so changes go through review like other configuration. Store the pipeline with the cluster API and fetch it back to confirm the saved definition matches the file. The step is done when the stored pipeline reads back exactly as written and a dry test request returns the processor without errors.

  4. Point the search request at the pipeline

    The application team adds the pipeline name to the search request, either as a default search pipeline on the index or as a per-request parameter. Set how many top results the reranker scores, since only that window is reordered, and keep it small enough for the latency budget agreed with the product owner. Include the original relevance score in the request so the team can compare before and after. The check is a search response that shows the reranked order and the original order side by side in a staging environment.

  5. Verify ordering on a judged query set

    The search team runs a fixed set of judged queries, where reviewers have already marked which results are relevant, against both the baseline query and the reranked query. They compare metrics such as how high the relevant documents rank, and they review a sample of queries by hand to catch regressions that metrics miss. The Search Relevance Workbench can hold these query sets and experiments. The step is done when the reranked configuration beats or matches the baseline on the agreed measures and the team has written down the queries that got worse and why.

  6. Check timeouts and latency under load

    The platform team measures end-to-end query latency with the reranker enabled, including model inference time and any connector round trip. They confirm the request timeout in the search pipeline and in the calling application, and they test what the user sees when the reranker times out, which should fall back to the original order rather than an error. Run a load test that matches expected peak traffic and record p95 and error rates. The step is done when the timeout fallback has been demonstrated and the measured latency sits within the budget the product team approved in writing.

Security and operational risks of a reranking layer

A rerank stage adds a second service to the query path, and that service may see user queries and result text. The cards below cover the controls, data flows and version dependencies to settle before the feature reaches production.

Access control on pipelines and models

Search pipelines and model registrations are cluster objects, so anyone who can create or modify them can change what runs on every query. Restrict pipeline and model management to a small admin role through the Security plugin, and keep application roles limited to searching. Review who can register a model endpoint, since that decision determines where query text is sent. Confirm the exact cluster permissions for these actions in the docs for your OpenSearch version.

Security docs

TLS to model endpoints

When a cross-encoder runs behind an HTTP endpoint, every query and candidate document crosses that connection. Require TLS between the cluster and the model service, validate the certificate chain, and confirm the trust store the cluster uses for outbound calls. Check whether the model service also authenticates the cluster, so that an unrelated workload on the same network cannot call it. Document the certificate owner and rotation process before go-live.

Text that leaves the cluster

A connector to a hosted model sends query strings and result fields outside your infrastructure, which can include personal data, customer names or internal identifiers. Decide which fields the rerank step reads, and strip or hash sensitive values before they reach the connector. Ask the provider where prompts and documents are processed and stored, whether they are logged, and whether they are used for training. Keep models hosted in the cluster when the data classification does not allow this transfer.

Query and result audit logging

Audit logs record who accessed which indices and when, and the rerank layer adds a path where query text may be copied into logs, traces or model provider records. Confirm which audit categories your deployment enables, and whether request bodies are included. Apply the same retention and access rules to any model-side logs as to search logs. Test that a reranked query leaves the trail your compliance team expects.

Upgrade coupling with the model runtime

The rerank processor depends on OpenSearch version features, and the model runtime, connector or hosting service has its own release cycle. Pin the OpenSearch version, the model runtime version and the model artifact together in your change records. Test each upgrade in a non-production cluster with the production query set before changing either component. Plan for a rollback path in which the search pipeline can be disabled without taking search offline.

OpenSearch releases

Questions teams ask before adding a cross-encoder reranker

Is a cross-encoder reranker worth adding to our OpenSearch search?

It is worth adding when the right result already appears in the candidate set but ranks too low, and users need that result near the top. Start by measuring it: collect a set of real queries, label which results are relevant, and check where the best answers land in the first-stage ranking. If they mostly sit beyond the first page or are missing entirely, reranking the top results will not fix the problem, and the work belongs in query analysis, synonyms or the first-stage query. Since OpenSearch 2.12, a search pipeline with the rerank processor can reorder results using scores from a cross-encoder model, so the feature itself is available. The open question is whether your queries and latency budget justify a second model call.

Can our in-house team build and run reranking without a partner?

Often yes, if you already run OpenSearch in production and have engineers who can build a search pipeline, test relevance and manage model hosting. The work splits into four parts: the search pipeline configuration, the model choice and hosting, the relevance evaluation, and the latency and capacity testing. Teams with no relevance measurement practice usually find the evaluation step takes the most effort, because it needs judgments that someone with domain knowledge must produce. A partner is useful when you want the pipeline, model connection and evaluation delivered as a fixed scope with a written handover, or when you need a second team to review the design.

What does the work need from our team?

Expect to supply four things: people who know what a good result looks like for your catalog or content, a sample of real queries with relevance judgments, hardware or cloud capacity for the model, and a decision on which model fits your language and latency needs. Relevance judgments are the input most often underestimated. Without them, you cannot tell whether reranking helped. Hardware depends on whether the model runs inside the cluster or behind a connector, so confirm the model's resource needs with its documentation and benchmark them on your own query volume before sizing anything.

How long does a reranking project take?

Duration depends on scope: whether you are adding a single pipeline to an existing relevance practice, or building the judgment set, comparing models and hardening the hosting from scratch. A narrow pilot on one search surface is much shorter than a multi-language rollout with latency targets per region. No supplied figure sets a standard duration here, so ask any partner, including DeployOpen, for a timeline tied to a written scope with named deliverables. Ask which steps depend on your team's availability, such as judgment labeling, because those steps often set the schedule more than the technical build does.

Does reranking add a license cost to our OpenSearch cluster?

The OpenSearch software is licensed under the Apache License, Version 2.0, and the OpenSearch FAQ does not describe any paid edition, so the search engine itself carries no license fee. Your costs come from the infrastructure that runs the cluster and the model, from the people who build and operate it, and from any commercial model or connector service you choose. Before you adopt a hosted model or API, check its own terms, because those are separate from OpenSearch. Ask any quote to list hardware or cloud capacity, model hosting, build effort and recurring tuning separately so you can see what recurs each month.

What breaks when we add a second-stage model to the query path?

The most common problem is latency: every query now waits for a model call on the top results, so the reranking window size and model size must fit your response budget. Other problems include model scores that shift after an upgrade, candidate sets that are too small to contain the right answer, and missing monitoring for timeouts that silently fall back to the first-stage ranking. Test response times at your real concurrency, set a timeout and fallback behavior, and log which results the model reordered so you can review changes. Confirm the rerank processor options and any connector settings against the OpenSearch documentation for your version.

Do model connectors send our search data outside our infrastructure?

It depends on where the model runs. A model hosted inside your cluster or your own infrastructure keeps query and document text within your environment, while a connector to an external model service sends that text to the provider. Review the provider's data handling terms, confirm which fields the rerank processor passes to the model, and remove fields that do not need to leave your network. Your security and compliance teams should approve the data flow before rollout, and the design should record it so reviewers can see where search text travels.

How DeployOpen scopes and delivers reranking on your OpenSearch cluster

DeployOpen plans, builds, tests, documents and supports self-hosted open-source platforms inside your own infrastructure, including OpenSearch search pipelines. For reranking, that means starting from your current relevance baseline and latency budget, then delivering a cross-encoder rerank stage that your team can operate and review.

How we scope

  • Written scope fixes which indexes, query types and result counts the rerank stage will cover on your cluster.
  • Scope records the cross-encoder model source, whether it runs in the cluster or through a connector, and who approves it.
  • Scope sets the latency budget, fallback behavior and the relevance measures that define success before any build starts.

How we build

  • We configure the search pipeline with the rerank processor and tune the number of documents rescored against your measured latency.
  • We test result ordering with your real query sets and check timeouts, error handling and fallback to the original ranking.
  • We review access controls on model endpoints and connector credentials, and confirm they follow your OpenSearch security configuration.

How we hand over

  • You receive pipeline definitions, connector configuration and model settings as versioned files your team can review.
  • Handover includes written runbooks for changing the model, adjusting the rerank depth and rolling back the pipeline.
  • We deliver test results, latency measurements and a list of open risks, so your team can repeat the checks after handover.

How we support

  • Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts. Quotes follow from that scope.
  • Ongoing support, upgrades and continuous testing are available as a retainer, including retesting after OpenSearch version updates.
  • Confirm with your team which OpenSearch version and rerank processor features your cluster supports before the scope is signed.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.