Skip to content

Add missing similarity field to KnnQuery and missing fields to KnnSea… #2224

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

Closed
wants to merge 11 commits into from
Closed
85 changes: 80 additions & 5 deletions output/schema/schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion output/typescript/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions specification/_global/knn_search/_types/Knn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,25 @@
*/

import { Field } from '@_types/common'
import { long, float } from '@_types/Numeric'
import { QueryVector } from '@_types/Knn'
import { long, float, double } from '@_types/Numeric'
import { QueryVector, QueryVectorBuilder } from '@_types/Knn'
import { QueryContainer } from '@_types/query_dsl/abstractions'

export interface Query {
/** The name of the vector field to search against */
field: Field
/** The query vector */
query_vector: QueryVector
query_vector?: QueryVector
/** The query vector builder. You must provide a query_vector_builder or query_vector, but not both. */
query_vector_builder?: QueryVectorBuilder
/** The final number of nearest neighbors to return as top hits */
k: long
/** The number of nearest neighbor candidates to consider per shard */
num_candidates: long
/** Boost value to apply to kNN scores */
boost?: float
/** Filters for the kNN search query */
filter?: QueryContainer | QueryContainer[]
/** The minimum similarity for a vector to be considered a match */
similarity?: double

Choose a reason for hiding this comment

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

@pstrsr hello, according to https://www.elastic.co/guide/en/elasticsearch/reference/8.10/knn-search-api.html the _knn_search API doesn't have similarity parameter.

I also want to see similarity parameter published: #2293 . Because of that I suggest to revert changes to this file completely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, it seems that I confused the APIs. Reverted the changes.

}
2 changes: 2 additions & 0 deletions specification/_types/Knn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export interface KnnQuery {
boost?: float
/** Filters for the kNN search query */
filter?: QueryContainer | QueryContainer[]
/** The minimum similarity for a vector to be considered a match */
similarity?: double
}

/** @variants container */
Expand Down