Elastic Search function_score property in root query in JS SDK 8.13

  Kiến thức lập trình

I’m using elastic SDK JS 8.13.
In my typescript code, I can see that the function_score property doesn’t exist in the type, at the root level of query.

enter image description here

Watching the type in in the lib, it is not present. But in the documentation here, it is used this way :

GET /_search
{
  "query": {
    "function_score": {
      "gauss": {
        "@timestamp": {
          "origin": "2013-09-17", 
          "scale": "10d",
          "offset": "5d",         
          "decay": 0.5            
        }
      }
    }
  }
}

(source)

I see that javascript is in grey in the dropdown of snippets in the source but Ruby and Python are available:

enter image description here

Can I use it in JS SDK 8.13? If no, How can I use it ? If you can give me an example please. I saw in types.d.ts that the prop was present in QueryDslQueryContainer. Should it be in a must array at the root level to influence score ?

Thank you
Yoann

LEAVE A COMMENT