OpenSearch/docs/painless
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 Update the signature of vector script functions. (#48653) 2019-10-29 15:46:05 -07:00
painless-contexts [DOCS] Moves Watcher content into Elasticsearch book (#47147) (#47255) 2019-09-30 10:18:50 -07:00
painless-guide [DOCS] Fix typos in Painless execute API docs(#47518) 2019-10-18 10:31:04 -04:00
painless-lang-spec [DOCS] Update painless statements with if/else example (#47485) 2019-10-03 15:23:54 -04:00
index.asciidoc Reorganize Painless doc structure (#42303) 2019-05-21 10:50:21 -07:00
painless-api-reference.asciidoc Task to generate Painless API's per context (#41233) 2019-04-23 11:28:27 -07:00
painless-contexts.asciidoc [DOCS] Moves Watcher content into Elasticsearch book (#47147) (#47255) 2019-09-30 10:18:50 -07:00
painless-guide.asciidoc Reorganize Painless doc structure (#42303) 2019-05-21 10:50:21 -07:00
painless-lang-spec.asciidoc Reorganize Painless doc structure (#42303) 2019-05-21 10:50:21 -07:00
redirects.asciidoc [DOCS] Add redirect for painless examples anchor 2019-06-25 12:34:18 -04:00