Skip to content

Commit 695183e

Browse files
committed
add tests for multiple values
1 parent 13182c7 commit 695183e

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

modules/lang-painless/src/yamlRestTest/resources/rest-api-spec/test/painless/50_script_doc_values.yml

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ setup:
7979
body:
8080
rank: 3
8181
boolean: [true, false, true]
82+
date: [2017-01-01T12:11:12, 2018-01-01T12:11:12]
83+
nanos: [2015-01-01T12:10:30.123456789Z, 2015-01-01T12:10:30.987654321Z]
8284
long: [1152921504606846976, 576460752303423488]
8385
integer: [5, 17, 29]
8486
short: [6, 18, 30, 45]
@@ -377,12 +379,45 @@ setup:
377379
search:
378380
rest_total_hits_as_int: true
379381
body:
380-
query: { term: { _id: 2 } }
382+
query: { term: { _id: 3 } }
381383
script_fields:
382384
field:
383385
script:
384-
source: "/* avoid yaml stash */ $('nanos', ZonedDateTime.parse('2016-01-01T12:10:30.123Z')).getNano()"
385-
- match: { hits.hits.0.fields.field.0: 123000000 }
386+
source: "field('date').get(1, null)"
387+
- match: { hits.hits.0.fields.field.0: "2018-01-01T12:11:12.000Z" }
388+
389+
- do:
390+
search:
391+
rest_total_hits_as_int: true
392+
body:
393+
query: { term: { _id: 3 } }
394+
script_fields:
395+
field:
396+
script:
397+
source: "field('nanos').get(1, null)"
398+
- match: { hits.hits.0.fields.field.0: "2015-01-01T12:10:30.987654321Z" }
399+
400+
- do:
401+
search:
402+
rest_total_hits_as_int: true
403+
body:
404+
query: { term: { _id: 3 } }
405+
script_fields:
406+
field:
407+
script:
408+
source: "List times = new ArrayList(); for (ZonedDateTime zdt : field('date')) times.add(zdt); times"
409+
- match: { hits.hits.0.fields.field: ["2017-01-01T12:11:12.000Z", "2018-01-01T12:11:12.000Z"] }
410+
411+
- do:
412+
search:
413+
rest_total_hits_as_int: true
414+
body:
415+
query: { term: { _id: 3 } }
416+
script_fields:
417+
field:
418+
script:
419+
source: "List times = new ArrayList(); for (ZonedDateTime zdt : field('nanos')) times.add(zdt); times"
420+
- match: { hits.hits.0.fields.field: ["2015-01-01T12:10:30.123456789Z", "2015-01-01T12:10:30.987654321Z"] }
386421

387422
---
388423
"geo_point":

0 commit comments

Comments
 (0)