Skip to content

Conversation

mridula-s109
Copy link
Contributor

Changes

  • RRFRetriever.retrievers: RetrieverContainer[]RRFRetrieverContainer[]
  • New RRFRetrieverContainer extends RetrieverContainer with optional weight?: float
  • Defaults to 1.0, must be non-negative

Related: elastic/elasticsearch#130658, elastic/elasticsearch#136477

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for weighted retrievers in the RRF (Reciprocal Rank Fusion) retriever by introducing a new weight parameter. The change allows individual retrievers to have different influence levels when combining their results.

  • Introduced RRFRetrieverContainer class extending RetrieverContainer with optional weight parameter
  • Updated RRFRetriever.retrievers type from RetrieverContainer[] to RRFRetrieverContainer[]
  • Added comprehensive documentation for the weight parameter behavior and constraints

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

github-actions bot commented Oct 16, 2025

Following you can find the validation changes against the target branch for the APIs.

API Status Request Response
index 🟢 1445/1445 → 1443/1443 1447/1447 → 1445/1445
indices.create 🔴 1378/1402 → 1385/1409 1402/1402 → 1409/1409
indices.refresh 🟢 329/329 → 327/327 329/329 → 327/327
ml.get_job_stats 🟢 30/30 → 29/29 30/30 → 29/29
ml.put_job 🟢 65/65 → 64/64 65/65 → 64/64

You can validate these APIs yourself by using the make validate target.

@leemthompo
Copy link
Contributor

You'll need to backport this to 9.2 right?

@mridula-s109 mridula-s109 added backport 9.2 and removed skip-backport This pull request should not be backported labels Oct 16, 2025
@mridula-s109 mridula-s109 reopened this Oct 16, 2025
@mridula-s109
Copy link
Contributor Author

You'll need to backport this to 9.2 right?

Thanks for the reminder! I've added the backport-9.2 label but the automation isn't triggering. Does the backport job only run after the PR is merged, or is there a specific way to trigger it manually?

@leemthompo
Copy link
Contributor

The backport job only runs after the PR is merged (if there are conflicts might need to use the manual backport tool to clean those up)

*/
export class RRFRetrieverContainer extends RetrieverContainer {
/** Weight multiplier for this retriever's contribution to the RRF score. Higher values increase influence. Defaults to 1.0 if not specified. Must be non-negative. */
weight?: float
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we also have to include the RetrieverContainer definition here as we have:

retrievers: [
   { 
         "retriever": {},
         "weight": 1
]

Maybe we could also combine with the nested structure of LinearRetriever which uses an InnerRetriever component.

@flobernd
Copy link
Member

flobernd commented Oct 17, 2025

Thanks for the PR @mridula-s109 !

From looking at the JSON example provided in elastic/elasticsearch#130658, @pmpailis seems to be right that the structure is not correct this way.

"retrievers": [ // <- RRFRetriever.retrievers
  {
    "retriever": { // <- RRFRetrieverComponent.retriever
      "standard": { // <- RetrieverContainer variant
        "query": { "match": { "description": "pizza" } } 
      }
    },
    "weight": 0.7 // <- RRFRetrieverComponent.weigth
  },

I think it should rather look like this:

export class RRFRetrieverComponent { // name taken from the server code
  retriever: RetrieverContainer
  weigth?: float
}

and

// In RRFRetriever:
retrievers: RRFRetrieverComponent[]

Btw.: I'm a little bit surprised that we ship this breaking change in a minor release. Is this expected?

Side note: For container variants, it's important to mark all fields that are not actual variants with the @container_property tag (see here).

@pmpailis
Copy link
Contributor

pmpailis commented Oct 17, 2025

Btw.: I'm a little bit surprised that we ship this breaking change in a minor release. Is this expected?

I think that this is an extension, i.e. an alternative format that we support, and not a breaking change. The previous format has not gone away (which also implies some adjustments in this PR)

@flobernd
Copy link
Member

@pmpailis

I think that this is an extension, i.e. an alternative format that we support, and not a breaking change. The previous format has not gone away

Ah right, I just saw the corresponding test cases 👍

which also implies some adjustments in this PR

Unfortunately. This kind of extension will result in an untagged/undiscriminated union in the specification - which is the worst possible construct to have for all statically typed clients 😐

@Anaethelion
Copy link
Contributor

I have removed the 9.2 backport label.
This sadly comes too late for us to include in the release of clients, especially with an untagged union which causes a breaking change in the API.
Please for now merge to main, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants