-
Notifications
You must be signed in to change notification settings - Fork 28
/
RegexpTest.kt
60 lines (53 loc) · 1.38 KB
/
RegexpTest.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
/*
* Copyright (c) 2016. Michael Buhot m.buhot@gmail.com
*/
package mbuhot.eskotlin.query.term
import mbuhot.eskotlin.query.should_render_as
import org.elasticsearch.index.query.RegexpFlag.*
import org.junit.Test
/**
* Created on 3/03/2016
* @author Michael Buhot (m.buhot@gmail.com)
*/
class RegexpTest {
@Test
fun `test regexp`() {
val query = regexp {
"name.first" to "s.*y"
}
query should_render_as """
{
"regexp" : {
"name.first": {
"value": "s.*y",
"flags_value": ${ALL.value()},
"max_determinized_states" : 10000,
"boost": 1.0
}
}
}
"""
}
@Test
fun `test regexp with boost and flags`() {
val query = regexp {
"name.first" {
value = "s.*y"
boost = 1.2f
flags = listOf(INTERSECTION, COMPLEMENT, EMPTY)
}
}
query should_render_as """
{
"regexp" : {
"name.first" : {
"value" : "s.*y",
"flags_value" : ${INTERSECTION.value() or COMPLEMENT.value() or EMPTY.value()},
"max_determinized_states" : 10000,
"boost" : 1.2
}
}
}
"""
}
}