Skip to content

Commit 76774d8

Browse files
authored
Add yaml test for random_score in function_score query (elastic#124893) (elastic#125003)
1 parent 296c7f5 commit 76774d8

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
"Random":
3+
- do:
4+
indices.create:
5+
index: test
6+
body:
7+
mappings:
8+
properties:
9+
text:
10+
type: text
11+
12+
- do:
13+
index:
14+
index: test
15+
id: "1"
16+
body: { text: "foo bar", uuid: 1234}
17+
18+
- do:
19+
index:
20+
index: test
21+
id: "2"
22+
body: { text: "high bar", uuid: 5678 }
23+
24+
- do:
25+
index:
26+
index: test
27+
id: "3"
28+
body: { text: "raise bar", uuid: 9012 }
29+
30+
- do:
31+
index:
32+
index: test
33+
id: "3"
34+
body: { text: "raise hands", uuid: 3456 }
35+
36+
- do:
37+
indices.refresh:
38+
index: [ test ]
39+
40+
- do:
41+
search:
42+
index: test
43+
body:
44+
size: 10
45+
query:
46+
"function_score": {
47+
"query": {
48+
"match": {
49+
"text": "bar"
50+
}
51+
},
52+
"random_score": {
53+
"seed": 10,
54+
"field": "_seq_no"
55+
}
56+
}
57+
58+
- length: { hits.hits: 2 }
59+
- match: { hits.total.value: 2 }
60+
61+
- do:
62+
search:
63+
index: test
64+
body:
65+
size: 10
66+
query:
67+
"function_score": {
68+
"query": {
69+
"match": {
70+
"text": "bar"
71+
}
72+
},
73+
"random_score": {
74+
"seed": 10
75+
}
76+
}
77+
78+
- length: { hits.hits: 2 }
79+
- match: { hits.total.value: 2 }
80+
81+
- do:
82+
search:
83+
index: test
84+
body:
85+
size: 10
86+
query:
87+
"function_score": {
88+
"query": {
89+
"match": {
90+
"text": "bar"
91+
}
92+
},
93+
"random_score": {
94+
"seed": 10,
95+
"field": "uuid"
96+
}
97+
}
98+
99+
- length: { hits.hits: 2 }
100+
- match: { hits.total.value: 2 }

0 commit comments

Comments
 (0)