Skip to content

Corrects a seemingly simple bug where we pass numCands instead of k#140839

Merged
elasticsearchmachine merged 8 commits intoelastic:mainfrom
benwtrent:pass-k-for-knn
Jan 17, 2026
Merged

Corrects a seemingly simple bug where we pass numCands instead of k#140839
elasticsearchmachine merged 8 commits intoelastic:mainfrom
benwtrent:pass-k-for-knn

Conversation

@benwtrent
Copy link
Member

Digging through the long and sordid history of this class, I noticed we previously passed in null, which would indicate "dynamic K" which defaulted to the size of the request.

However, in an effort to simplify the APIs when we rewrote these paths for rescoring, I switched this to numCands.

But, since then @pmpailis actually fixed all the default logic in the Builder#build(int) parameter, correctly defaulting k and numCands.

So, we SHOULD be able to pass in k. A quick check of our yaml tests and they all passed...let's see what CI says.

While this is a bug, it would adjust behavior slightly, so only considering the latest bugfix. I could be convinced to backport everywhere if CI is happy.

@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Jan 16, 2026
@elasticsearchmachine
Copy link
Collaborator

Hi @benwtrent, I've created a changelog YAML for you.

@elasticsearchmachine
Copy link
Collaborator

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

Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

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

LGTM, ++ to backport as well.

@benwtrent benwtrent added auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) auto-backport Automatically create backport pull requests when merged labels Jan 16, 2026
Copy link
Contributor

@mayya-sharipova mayya-sharipova left a comment

Choose a reason for hiding this comment

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

Thanks @benwtrent , makes sense

@elasticsearchmachine elasticsearchmachine merged commit 338ee3d into elastic:main Jan 17, 2026
35 checks passed
@benwtrent benwtrent deleted the pass-k-for-knn branch January 17, 2026 14:03
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
9.3
benwtrent added a commit to benwtrent/elasticsearch that referenced this pull request Jan 17, 2026
…lastic#140839)

Digging through the long and sordid history of this class, I noticed we
previously passed in `null`, which would indicate "dynamic K" which
defaulted to the size of the request.

However, in an effort to simplify the APIs when we rewrote these paths
for rescoring, I switched this to numCands.

But, since then @pmpailis actually fixed all the default logic in the
`Builder#build(int)` parameter, correctly defaulting `k` and `numCands`.


So, we SHOULD be able to pass in `k`. A quick check of our yaml tests
and they all passed...let's see what CI says.

While this is a bug, it would adjust behavior slightly, so only
considering the latest bugfix. I could be convinced to backport
everywhere if CI is happy.
elasticsearchmachine pushed a commit that referenced this pull request Jan 17, 2026
…140839) (#140852)

Digging through the long and sordid history of this class, I noticed we
previously passed in `null`, which would indicate "dynamic K" which
defaulted to the size of the request.

However, in an effort to simplify the APIs when we rewrote these paths
for rescoring, I switched this to numCands.

But, since then @pmpailis actually fixed all the default logic in the
`Builder#build(int)` parameter, correctly defaulting `k` and `numCands`.


So, we SHOULD be able to pass in `k`. A quick check of our yaml tests
and they all passed...let's see what CI says.

While this is a bug, it would adjust behavior slightly, so only
considering the latest bugfix. I could be convinced to backport
everywhere if CI is happy.
spinscale pushed a commit to spinscale/elasticsearch that referenced this pull request Jan 21, 2026
…lastic#140839)

Digging through the long and sordid history of this class, I noticed we
previously passed in `null`, which would indicate "dynamic K" which
defaulted to the size of the request.

However, in an effort to simplify the APIs when we rewrote these paths
for rescoring, I switched this to numCands.

But, since then @pmpailis actually fixed all the default logic in the
`Builder#build(int)` parameter, correctly defaulting `k` and `numCands`.


So, we SHOULD be able to pass in `k`. A quick check of our yaml tests
and they all passed...let's see what CI says.

While this is a bug, it would adjust behavior slightly, so only
considering the latest bugfix. I could be convinced to backport
everywhere if CI is happy.
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 auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) >bug :Search Relevance/Vectors Vector search Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v9.3.1 v9.4.0

4 participants