Skip to content

Retrievers - Fix rank_window_size validation #128108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ioanatia
Copy link
Contributor

When passing a negative rank_window_size to a compound retriever, we return an error message that references size instead of rank_window_size:

POST search-movies/_search
{
  "retriever": {
    "rrf": {
      "retrievers": [
        {
          "standard": {
            "query": {
              "match": {
                "title": "Shakespeare"
              }
            }
          }
        },
                {
          "standard": {
            "query": {
              "match": {
                "title": "Shakespeare"
              }
            }
          }
        }
      ],
      "rank_window_size": -1
    }
  }
}

Response:

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "[size] parameter cannot be negative, found [-1]"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "[size] parameter cannot be negative, found [-1]"
  },
  "status": 400
}

This is coming from:

if (size < 0) {
throw new IllegalArgumentException("[size] parameter cannot be negative, found [" + size + "]");
}

This validation needs to happen at the compound retriever level.

Besides fixing the error message, I also moved rankWindowSize to the base class for compound retrievers, instead of having it duplicated in 3 inherited retrievers.

@ioanatia ioanatia added :Search/Search Search-related issues that do not fall into other categories Team:Search - Relevance The Search organization Search Relevance team labels May 16, 2025
@elasticsearchmachine elasticsearchmachine added v9.1.0 Team:Search Meta label for search team and removed Team:Search - Relevance The Search organization Search Relevance team labels May 16, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

@ioanatia ioanatia changed the title Retrivers - Fix rank_window_size validation Retrievers - Fix rank_window_size validation May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants