Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions modules/lang-painless/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,47 @@ tasks.named("test").configure {
jvmArgs '-XX:-OmitStackTraceInFastThrow', '-XX:-HeapDumpOnOutOfMemoryError'
}

tasks.named("yamlRestTestV7CompatTest").configure {
systemProperty 'tests.rest.blacklist', [
'painless/20_scriptfield/Scripted Field Doing Compare (fields api)',
'painless/70_execute_painless_scripts/Execute with double field context (single-value, fields api)',
'painless/70_execute_painless_scripts/Execute with double field context (single-value, fields api)',
'70_execute_painless_scripts/Execute with geo point field context (multi-value, fields api)',
'70_execute_painless_scripts/Execute with ip field context (single-value, fields api)',
'70_execute_painless_scripts/Execute with boolean field context (single-value, fields api)',
'painless/70_execute_painless_scripts/Execute with boolean field context (multi-value, fields api)',
'painless/40_fields_api/date to long',
'painless/130_metric_agg/Scripted Metric Agg Total (fields api)',
'painless/70_execute_painless_scripts/Execute with keyword field context (multi-value, fields api)',
'painless/100_terms_agg/Double Value Script with doc notation (fields api)',
'painless/100_terms_agg/Long Value Script with doc notation (fields api)',
'painless/20_scriptfield/Access a date (fields api)',
'painless/70_execute_painless_scripts/Execute with date field context (multi-value, fields api)',
'painless/70_execute_painless_scripts/Execute with keyword field context (single-value, fields api)',
'painless/70_execute_painless_scripts/Execute with long field context (multi-value, fields api)',
'painless/20_scriptfield/Scripted Field (fields api)',
'painless/70_execute_painless_scripts/Execute with long field context (single-value, fields api)',
'painless/70_execute_painless_scripts/Execute with geo point field context (single-value, fields api)',
'painless/70_execute_painless_scripts/Execute with date field context (single-value, fields api)',
'painless/40_fields_api/missing field',
'painless/40_fields_api/sort script fields api',
'painless/20_scriptfield/Access many dates (fields api)',
'painless/70_execute_painless_scripts/Execute with long field context (single-value, fields api)',
'painless/70_execute_painless_scripts/Execute with geo point field context (single-value, fields api)',
'painless/70_execute_painless_scripts/Execute with date field context (single-value, fields api)',
'painless/40_fields_api/missing field',
'painless/40_fields_api/sort script fields api',
'painless/20_scriptfield/Access many dates (fields api)',
'painless/100_terms_agg/String Value Script with doc notation (fields api)',
'painless/40_fields_api/string to long and bigint',
'painless/40_fields_api/boolean to long and bigint',
'painless/40_fields_api/script fields api for dates',
'painless/70_execute_painless_scripts/Execute with double field context (multi-value, fields api)',
'painless/40_fields_api/filter script fields api',
'painless/40_fields_api/script score fields api'
].join(',')
}

/* Build Javadoc for the Java classes in Painless's public API that are in the
* Painless plugin */
tasks.register("apiJavadoc", Javadoc) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,13 @@
# The whitelist for the fields api

# API
class org.elasticsearch.script.field.Field {
org.elasticsearch.script.field.Converter BigInteger @augmented[augmented_canonical_class_name="org.elasticsearch.script.field.BigIntegerField"]
org.elasticsearch.script.field.Converter Long @augmented[augmented_canonical_class_name="org.elasticsearch.script.field.LongField"]
class org.elasticsearch.script.field.Field @dynamic_type {
String getName()
boolean isEmpty()
int size()
List getValues()
def getValue(def)
double getDouble(double)
long getLong(long)
org.elasticsearch.script.field.Field as(org.elasticsearch.script.field.Converter)
}

class org.elasticsearch.script.field.Converter {
def getValue(int, def)
}

class org.elasticsearch.script.DocBasedScript {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,6 @@ setup:
- is_false: aggregations.str_terms.buckets.1.key_as_string
- match: { aggregations.str_terms.buckets.1.doc_count: 1 }

---
"String Value Script with doc notation (fields api)":

- do:
search:
rest_total_hits_as_int: true
body: { "size" : 0, "aggs" : { "str_terms" : { "terms" : { "field" : "str", "script": { "source": "return field('str').getValue('') + \"1\""} } } } }

- match: { hits.total: 3 }

- length: { aggregations.str_terms.buckets: 2 }
- match: { aggregations.str_terms.buckets.0.key: "abc1" }
- is_false: aggregations.str_terms.buckets.0.key_as_string
- match: { aggregations.str_terms.buckets.0.doc_count: 2 }
- match: { aggregations.str_terms.buckets.1.key: "bcd1" }
- is_false: aggregations.str_terms.buckets.1.key_as_string
- match: { aggregations.str_terms.buckets.1.doc_count: 1 }

---
"Long Value Script with doc notation":

Expand All @@ -102,24 +84,6 @@ setup:
- is_false: aggregations.long_terms.buckets.1.key_as_string
- match: { aggregations.long_terms.buckets.1.doc_count: 1 }

---
"Long Value Script with doc notation (fields api)":

- do:
search:
rest_total_hits_as_int: true
body: { "size" : 0, "aggs" : { "long_terms" : { "terms" : { "field" : "number", "script": { "source": "return field('number').getValue(0L) + 1"} } } } }

- match: { hits.total: 3 }

- length: { aggregations.long_terms.buckets: 2 }
- match: { aggregations.long_terms.buckets.0.key: 2.0 }
- is_false: aggregations.long_terms.buckets.0.key_as_string
- match: { aggregations.long_terms.buckets.0.doc_count: 2 }
- match: { aggregations.long_terms.buckets.1.key: 3.0 }
- is_false: aggregations.long_terms.buckets.1.key_as_string
- match: { aggregations.long_terms.buckets.1.doc_count: 1 }

---
"Double Value Script with doc notation":

Expand All @@ -138,24 +102,6 @@ setup:
- is_false: aggregations.double_terms.buckets.1.key_as_string
- match: { aggregations.double_terms.buckets.1.doc_count: 1 }

---
"Double Value Script with doc notation (fields api)":

- do:
search:
rest_total_hits_as_int: true
body: { "size" : 0, "aggs" : { "double_terms" : { "terms" : { "field" : "double", "script": { "source": "return field('double').getValue(0.0) + 1"} } } } }

- match: { hits.total: 3 }

- length: { aggregations.double_terms.buckets: 2 }
- match: { aggregations.double_terms.buckets.0.key: 2.0 }
- is_false: aggregations.double_terms.buckets.0.key_as_string
- match: { aggregations.double_terms.buckets.0.doc_count: 2 }
- match: { aggregations.double_terms.buckets.1.key: 3.0 }
- is_false: aggregations.double_terms.buckets.1.key_as_string
- match: { aggregations.double_terms.buckets.1.doc_count: 1 }

---
"Bucket script with keys":

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,3 @@ setup:
- match: { hits.total: 3 }
- match: { aggregations.total.value: 4.0 }

---
"Scripted Metric Agg Total (fields api)":

- do:
search:
rest_total_hits_as_int: true
body: {
"size": 0,
"aggs": {
"total": {
"scripted_metric": {
"init_script": "state.transactions = []",
"map_script": "state.transactions.add(field('double').getValue(0.0))",
"combine_script": "double total = 0.0; for (t in state.transactions) { total += t } return total",
"reduce_script": "double total = 0; for (a in states) { total += a } return total"
}
}
}
}

- match: { hits.total: 3 }
- match: { aggregations.total.value: 4.0 }
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,6 @@ setup:

- match: { hits.hits.0.fields.bar.0: "aaabbb"}

---
"Scripted Field (fields api)":
- do:
search:
rest_total_hits_as_int: true
body:
script_fields:
bar:
script:
source: "field('foo').getValue('') + params.x;"
params:
x: "bbb"

- match: { hits.hits.0.fields.bar.0: "aaabbb"}

---
"Scripted Field Doing Compare":
- do:
Expand Down Expand Up @@ -88,35 +73,6 @@ setup:

- match: { hits.hits.0.fields.bar.0: false}

---
"Scripted Field Doing Compare (fields api)":
- do:
search:
rest_total_hits_as_int: true
body:
script_fields:
bar:
script:
source: "boolean compare(Supplier s, def v) {return s.get() == v;}
compare(() -> { return field('foo').getValue('') }, params.x);"
params:
x: "aaa"

- match: { hits.hits.0.fields.bar.0: true}
- do:
search:
rest_total_hits_as_int: true
body:
script_fields:
bar:
script:
source: "boolean compare(Supplier s, def v) {return s.get() == v;}
compare(() -> { return doc['foo'].value }, params.x);"
params:
x: "bbb"

- match: { hits.hits.0.fields.bar.0: false}

---
"Scripted Field with a null safe dereference (non-null)":
- do:
Expand Down Expand Up @@ -160,19 +116,6 @@ setup:

- match: { hits.hits.0.fields.bar.0: 7}

---
"Access a date (fields api)":
- do:
search:
rest_total_hits_as_int: true
body:
script_fields:
bar:
script:
source: "field('date').getValue(new Date()).dayOfWeekEnum.value"

- match: { hits.hits.0.fields.bar.0: 7}

---
"Access many dates":
- do:
Expand All @@ -191,24 +134,6 @@ setup:

- match: { hits.hits.0.fields.bar.0: "7 3 3"}

---
"Access many dates (fields api)":
- do:
search:
rest_total_hits_as_int: true
body:
script_fields:
bar:
script:
source: >
StringBuilder b = new StringBuilder();
for (def date : field('dates').getValues()) {
b.append(" ").append(date.getDayOfWeekEnum().value);
}
return b.toString().trim()

- match: { hits.hits.0.fields.bar.0: "7 3 3"}

---
"Scripted Field with script error":
- do:
Expand Down
Loading