forked from mbuhot/eskotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNestedTest.kt
81 lines (75 loc) · 2.6 KB
/
NestedTest.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
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Copyright (c) 2016. Michael Buhot [email protected]
*/
package mbuhot.eskotlin.query.joining
import mbuhot.eskotlin.query.compound.bool
import mbuhot.eskotlin.query.fulltext.match
import mbuhot.eskotlin.query.should_render_as
import mbuhot.eskotlin.query.term.range
import org.apache.lucene.search.join.ScoreMode
import org.junit.Test
/**
* Created on 3/03/2016
* @author Michael Buhot ([email protected])
*/
class NestedTest {
@Test
fun `test nested`() {
val query = nested {
path = "obj1"
score_mode = ScoreMode.Avg
query {
bool {
must = listOf(
match { "obj1.name" to "blue" },
range { "obj1.count" { gt = 5 } }
)
}
}
}
query should_render_as """
{
"nested" : {
"query" : {
"bool" : {
"must" : [
{
"match" : {
"obj1.name" : {
"query": "blue",
"operator": "OR",
"prefix_length": 0,
"max_expansions": 50,
"fuzzy_transpositions": true,
"lenient": false,
"zero_terms_query": "NONE",
"auto_generate_synonyms_phrase_query": true,
"boost": 1.0
}
}
},
{
"range" : {
"obj1.count" : {
"from" : 5,
"to" : null,
"include_lower" : false,
"include_upper" : true,
"boost": 1.0
}
}
}
],
"adjust_pure_negative":true,
"boost":1.0
}
},
"path" : "obj1",
"ignore_unmapped":false,
"score_mode" : "avg",
"boost": 1.0
}
}
"""
}
}