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

Merged
merged 4 commits into from
May 19, 2025

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
@ioanatia ioanatia requested a review from a team May 18, 2025 13:40
Copy link
Contributor

@pmpailis pmpailis left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@Mikep86 Mikep86 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for fix! Left one non-blocking nit.

@Mikep86 Mikep86 added auto-backport Automatically create backport pull requests when merged v8.19.0 labels May 19, 2025
Copy link
Member

@kderusso kderusso left a comment

Choose a reason for hiding this comment

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

LGTM

@ioanatia ioanatia enabled auto-merge (squash) May 19, 2025 15:35
@ioanatia ioanatia merged commit e9a8efe into elastic:main May 19, 2025
15 of 17 checks passed
Mikep86 pushed a commit to Mikep86/elasticsearch that referenced this pull request May 19, 2025
(cherry picked from commit e9a8efe)

# Conflicts:
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilder.java
#	x-pack/plugin/search-business-rules/src/main/java/org/elasticsearch/xpack/searchbusinessrules/retriever/PinnedRetrieverBuilder.java
Mikep86 pushed a commit to Mikep86/elasticsearch that referenced this pull request May 19, 2025
(cherry picked from commit e9a8efe)

# Conflicts:
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilder.java
Mikep86 pushed a commit to Mikep86/elasticsearch that referenced this pull request May 19, 2025
(cherry picked from commit e9a8efe)

# Conflicts:
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilder.java
#	x-pack/plugin/search-business-rules/src/main/java/org/elasticsearch/xpack/searchbusinessrules/retriever/PinnedRetrieverBuilder.java
@Mikep86
Copy link
Contributor

Mikep86 commented May 19, 2025

💚 All backports created successfully

Status Branch Result
9.0
8.19
8.18

Questions ?

Please refer to the Backport tool documentation

elasticsearchmachine pushed a commit that referenced this pull request May 19, 2025
* Retrievers - Fix rank_window_size validation (#128108)

(cherry picked from commit e9a8efe)

# Conflicts:
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilder.java
#	x-pack/plugin/search-business-rules/src/main/java/org/elasticsearch/xpack/searchbusinessrules/retriever/PinnedRetrieverBuilder.java

* Fix build error

---------

Co-authored-by: Ioana Tagirta <[email protected]>
elasticsearchmachine pushed a commit that referenced this pull request May 19, 2025
* Retrievers - Fix rank_window_size validation (#128108)

(cherry picked from commit e9a8efe)

# Conflicts:
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilder.java

* Fix build error

---------

Co-authored-by: Ioana Tagirta <[email protected]>
elasticsearchmachine pushed a commit that referenced this pull request May 19, 2025
* Retrievers - Fix rank_window_size validation (#128108)

(cherry picked from commit e9a8efe)

# Conflicts:
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rank/textsimilarity/TextSimilarityRankRetrieverBuilder.java
#	x-pack/plugin/search-business-rules/src/main/java/org/elasticsearch/xpack/searchbusinessrules/retriever/PinnedRetrieverBuilder.java

* Fix build error

---------

Co-authored-by: Ioana Tagirta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Automatically create backport pull requests when merged >non-issue :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team v8.18.2 v8.19.0 v9.0.2 v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants