mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-28 17:34:17 -04:00
Switch over dynamic method calls, loads and stores to invokedynamic.
Remove performance hack for accessing a document's fields, its not needed. Add support for accessing is-getter methods like List.isEmpty() as .empty Closes #18201
This commit is contained in:
parent
5a7edf992c
commit
ba2fe156e8
21 changed files with 1182 additions and 652 deletions
|
@ -199,38 +199,6 @@ POST hockey/player/1/_update
|
|||
----------------------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
[float]
|
||||
=== Writing Type-Safe Scripts to Improve Performance
|
||||
|
||||
If you explicitly specify types, the compiler doesn't have to perform type lookups at runtime, which can significantly
|
||||
improve performance. For example, the following script performs the same first name, last name sort we showed before,
|
||||
but it's fully type-safe.
|
||||
|
||||
[source,js]
|
||||
----------------------------------------------------------------
|
||||
GET hockey/_search
|
||||
{
|
||||
"query": {
|
||||
"match_all": {}
|
||||
},
|
||||
"script_fields": {
|
||||
"full_name_dynamic": {
|
||||
"script": {
|
||||
"lang": "painless",
|
||||
"inline": "def first = input.doc['first'].value; def last = input.doc['last'].value; return first + ' ' + last;"
|
||||
}
|
||||
},
|
||||
"full_name_static": {
|
||||
"script": {
|
||||
"lang": "painless",
|
||||
"inline": "String first = (String)((List)((Map)input.get('doc')).get('first')).get(0); String last = (String)((List)((Map)input.get('doc')).get('last')).get(0); return first + ' ' + last;"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
----------------------------------------------------------------
|
||||
// CONSOLE
|
||||
|
||||
[[painless-api]]
|
||||
[float]
|
||||
== Painless API
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue