elastic / elasticsearch-js

Official Elasticsearch client library for Node.js
https://ela.st/js-client
Apache License 2.0
5.24k stars 727 forks source link

Incorrect TypeScript typings for `function_score` #2255

Open arslivinski opened 4 months ago

arslivinski commented 4 months ago

🐛 Bug Report

According to the documentation, I should be able to pass a random_score to a function_score. However, the TypeScript type appears to be wrong, not allowing this property.

Note that I'm using this package for the typings only.

To Reproduce

The following code

import type { estypes } from "@elastic/elasticsearch";

export const request: estypes.SearchRequest = {
  query: {
    function_score: {
      random_score: {
        seed: 10,
        field: "_seq_no",
      },
    },
  },
};

Results in this error

Object literal may only specify known properties, and 'random_score' does not exist in type 'QueryDslFunctionScoreQuery'.

Playground

Expected behavior

No error.

Your Environment

JoshMock commented 3 months ago

Duplicate of https://github.com/elastic/elasticsearch-specification/issues/2109, but I'll keep it open here so you get notified when that gets fixed. It's been sitting for a bit, but hopefully I can circle back to it soon. :upside_down_face:

JoshMock commented 1 week ago

A fix has been provided in https://github.com/elastic/elasticsearch-specification/pull/2833. Closing this, please follow that PR for updates.

JoshMock commented 1 week ago

Reopening. I misread the description; that fix does not cover the exact issue here.

JoshMock commented 5 days ago

A fix is in https://github.com/elastic/elasticsearch-specification/pull/2852.