-
Notifications
You must be signed in to change notification settings - Fork 28
/
NestedAggregationTest.kt
69 lines (66 loc) · 1.83 KB
/
NestedAggregationTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package mbuhot.eskotlin.aggregation
import mbuhot.eskotlin.query.compound.bool
import mbuhot.eskotlin.query.should_render_as
import mbuhot.eskotlin.query.term.exists
import mbuhot.eskotlin.query.term.term
import org.junit.Test
class NestedAggregationTest {
@Test
fun `nested_aggregation should`() {
val agg = nested_aggregation {
name = "nested_aggregation"
path = "path"
sub_aggregation = listOf(
filterAggregation {
name = "expiry"
filter = bool {
must_not { exists { field = "expiryDate" } }
}
},
filterAggregation {
name = "status"
filter = term {
"user" to "Kimchy"
}
}
)
}
agg should_render_as """
{
"nested_aggregation": {
"nested": {
"path": "path"
},
"aggregations": {
"expiry": {
"filter": {
"bool": {
"must_not": [
{
"exists": {
"field": "expiryDate",
"boost": 1.0
}
}
],
"adjust_pure_negative": true,
"boost": 1.0
}
}
},
"status": {
"filter": {
"term": {
"user": {
"value": "Kimchy",
"boost": 1.0
}
}
}
}
}
}
}
""".trimIndent()
}
}