OpenSearch/docs/painless/painless-api-reference
Julie Tibshirani 89c65752dc
Update the signature of vector script functions. (#48653)
Previously the functions accepted a doc values reference, whereas they now
accept the name of the vector field. Here's an example of how a vector function
was called before and after the change.

```
Before: cosineSimilarity(params.query_vector, doc['field'])
After:  cosineSimilarity(params.query_vector, 'field')
```

This seems more intuitive, since we don't allow direct access to vector doc
values and the the meaning of `doc['field']` is unclear.

The PR makes the following changes (broken into distinct commits):
* Add new function signatures of the form `function(params.query_vector,
'field')` and deprecates the old ones. Because Painless doesn't allow two
methods with the same name and number of arguments, we allow a generic `Object`
to be passed in to the function and decide on the behavior through an
`instanceof` check.
* Refactor the class bindings so that the document field is passed to the
constructor instead of the instance method. This allows us to avoid retrieving
the vector doc values on every function invocation, which gives a tiny speed-up
in benchmarks.

Note that this PR adds new signatures for the sparse vector functions too, even
though sparse vectors are deprecated. It seemed simplest to understand (for both
us and users) to keep everything symmetric between dense and sparse vectors.
2019-10-29 15:46:05 -07:00
..
painless-api-reference-analysis Add static section whitelist info to api docs generation (#41870) 2019-05-08 11:15:38 -07:00
painless-api-reference-field Add static section whitelist info to api docs generation (#41870) 2019-05-08 11:15:38 -07:00
painless-api-reference-ingest Add static section whitelist info to api docs generation (#41870) 2019-05-08 11:15:38 -07:00
painless-api-reference-moving-function Add static section whitelist info to api docs generation (#41870) 2019-05-08 11:15:38 -07:00
painless-api-reference-score Update the signature of vector script functions. (#48653) 2019-10-29 15:46:05 -07:00
painless-api-reference-shared Add painless method getByPath, get value from nested collections with dotted path (#43170) (#43606) 2019-06-26 09:06:34 -06:00
index.asciidoc Add static section whitelist info to api docs generation (#41870) 2019-05-08 11:15:38 -07:00