Skip to content

Commit ed6f965

Browse files
committed
Use nested query in nested field test
Also, add a test that actually returns a document.
1 parent 3c669c0 commit ed6f965

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/160_nested_fields.yml

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
- do:
3434
index:
3535
index: test
36-
body: { "@timestamp": "2021-04-28T01:00:00Z", "department": "compsci", "staff": 12, "courses": [ { "name": "Object Oriented Programming", "credits": 3 }, { "name": "Theory of Computation", "credits": 4, } ] }
36+
body: { "@timestamp": "2021-04-28T01:00:00Z", "department": "compsci", "staff": 12, "courses": [ { "name": "Object Oriented Programming", "credits": 3 }, { "name": "Theory of Computation", "credits": 4 } ] }
3737

3838
- do:
3939
index:
@@ -50,12 +50,34 @@
5050
body:
5151
size: 0
5252
query:
53-
bool:
54-
must:
55-
- term:
56-
courses.name: Precalculus
57-
- term:
58-
courses.credits: 3
53+
nested:
54+
path: "courses"
55+
query:
56+
bool:
57+
must:
58+
- term:
59+
courses.name: Precalculus
60+
- term:
61+
courses.credits: 3
5962

60-
- match:
61-
hits.total.value: 0
63+
- match: { hits.total.value: 0 }
64+
65+
- do:
66+
search:
67+
index: test
68+
body:
69+
query:
70+
nested:
71+
path: "courses"
72+
query:
73+
bool:
74+
must:
75+
- term:
76+
courses.name: "Object Oriented Programming"
77+
- term:
78+
courses.credits: 3
79+
80+
- match: { hits.total.value: 1 }
81+
- match: { "hits.hits.0._source.@timestamp": "2021-04-28T01:00:00.000Z" }
82+
- match: { hits.hits.0._source.department: "compsci" }
83+
- match: { hits.hits.0._source.courses: [ { "name": "Object Oriented Programming", "credits": 3 }, { "name": "Theory of Computation", "credits": 4, } ] }

0 commit comments

Comments
 (0)