-
Notifications
You must be signed in to change notification settings - Fork 69
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
function_score
type in QueryDslQueryContainer
interface seems incorrect
#2109
Comments
@ohueter Just moved this to the The fix that you made in elastic/elasticsearch-js#1745 would be accomplished via the code generator by modifying the following line: to be function_score?: FunctionScoreQuery | FunctionScoreContainer I'm not very familiar with this particular API, so I'm pinging @swallez to verify that this seems like an accurate change to that type. If this is correct, you can rebase your PR and I'll merge it, then update the spec here to match. |
This one is tricky... So a correct fix would be to clone After renaming function_score?: FunctionScoreQuery
/** @codegen_names single multi */
export type FunctionScore = SingleFunctionScoreContainer | MultiFunctionScoreQuery
/** @variants container */
export class SingleFunctionScoreContainer {
exp?: DecayFunction
gauss?: DecayFunction
linear?: DecayFunction
field_value_factor?: FieldValueFactorScoreFunction
random_score?: RandomScoreFunction
script_score?: ScriptScoreFunction
/** @variant container_property */
filter?: QueryContainer
/** @variant container_property */
weight?: double
// WARNING: keep below properties in sync with SingleFunctionScoreContainer
/** @variant container_property */
boost_mode?: FunctionBoostMode
/** @variant container_property */
max_boost?: double
/** @variant container_property */
min_score?: double
/** @variant container_property */
query?: QueryContainer
/** @variant container_property */
score_mode?: FunctionScoreMode
} This is quite complex to allow a shortcut with a single function, which can also be expressed using a single element function array with the current spec. Also note that this would be a breaking change for languages (like Java) that do not have native unions. These languages will likely want to add a model preparation tweak that only keeps the multi-function variant. Additional note: the ES server accepts the single-function variant as input but will always serialize as the multi-function variant. |
Got another issue that appears to have the same underlying cause as this one. Need to get back to it soon! |
🐛 Bug Report
The
function_score
type in theQueryDslQueryContainer
interface seems to be incorrect.I implemented the first example from the Function score query docs in TypeScript:
which results in the following type error:
Expected behavior
No type error should occur. I'm not familiar with the code base, the correct fix seems to change the
function_score
type in theQueryDslQueryContainer
interface fromto
Hoping this is the correct solution, I went ahead and created a PR for this change: elastic/elasticsearch-js#1745
It's tested to be working with a running Elastic instance :-)
Your Environment
@elastic/elasticsearch
version: >=7.16.0The text was updated successfully, but these errors were encountered: