Skip to content

Commit 7bac548

Browse files
authored
Integration test for sample aggragator (backport of #77807) (#77816)
Adds and integration test for the sample aggregator. It's a fairly simple aggregator - you can only chose how many documents it samples.
1 parent 42ba7cd commit 7bac548

File tree

1 file changed

+80
-0
lines changed
  • rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.aggregation

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
setup:
2+
- do:
3+
indices.create:
4+
index: test
5+
body:
6+
settings:
7+
number_of_shards: 1
8+
mappings:
9+
properties:
10+
tags:
11+
type: text
12+
number:
13+
type: integer
14+
15+
- do:
16+
bulk:
17+
index: test
18+
refresh: true
19+
body:
20+
- '{"index": {}}'
21+
- '{"tags": "kibana", "number": 1}'
22+
- '{"index": {}}'
23+
- '{"tags": "kibana", "number": 2}'
24+
- '{"index": {}}'
25+
- '{"tags": "kibana", "number": 3}'
26+
- '{"index": {}}'
27+
- '{"tags": "javascript", "number": 4}'
28+
29+
---
30+
small shard_size:
31+
- do:
32+
search:
33+
rest_total_hits_as_int: true
34+
body:
35+
query:
36+
query_string:
37+
query: 'tags:kibana OR tags:javascript'
38+
aggs:
39+
sample:
40+
sampler:
41+
shard_size: 1
42+
aggs:
43+
min_number:
44+
min:
45+
field: number
46+
max_number:
47+
max:
48+
field: number
49+
50+
- match: { hits.total: 4 }
51+
- match: { aggregations.sample.doc_count: 1 }
52+
# The document with 4 has the highest score so we pick that one.
53+
- match: { aggregations.sample.min_number.value: 4.0 }
54+
- match: { aggregations.sample.max_number.value: 4.0 }
55+
56+
---
57+
default shard size:
58+
- do:
59+
search:
60+
rest_total_hits_as_int: true
61+
body:
62+
query:
63+
query_string:
64+
query: 'tags:kibana OR tags:javascript'
65+
aggs:
66+
sample:
67+
sampler: {}
68+
aggs:
69+
min_number:
70+
min:
71+
field: number
72+
max_number:
73+
max:
74+
field: number
75+
76+
- match: { hits.total: 4 }
77+
# The default shard size is much larger than the four test documents we are working with
78+
- match: { aggregations.sample.doc_count: 4 }
79+
- match: { aggregations.sample.min_number.value: 1.0 }
80+
- match: { aggregations.sample.max_number.value: 4.0 }

0 commit comments

Comments
 (0)