Skip to content

Commit 4e71c04

Browse files
authored
Adding more tests for rank_vectors for hex string case (#123185)
1 parent 3295149 commit 4e71c04

File tree

1 file changed

+52
-8
lines changed

1 file changed

+52
-8
lines changed

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/rank_vectors/rank_vectors_max_sim.yml

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ setup:
1414
mappings:
1515
properties:
1616
vector:
17-
type: rank_vectors
18-
dims: 5
17+
type: rank_vectors
18+
dims: 5
1919
byte_vector:
20-
type: rank_vectors
21-
dims: 5
22-
element_type: byte
20+
type: rank_vectors
21+
dims: 5
22+
element_type: byte
2323
bit_vector:
2424
type: rank_vectors
2525
dims: 40
@@ -39,8 +39,8 @@ setup:
3939
id: "3"
4040
body:
4141
vector: [[0.5, 111.3, -13.0, 14.8, -156.0]]
42-
byte_vector: [[2, 18, -5, 0, -124]]
43-
bit_vector: [[2, 18, -5, 0, -124]]
42+
byte_vector: ["0212fb0084"]
43+
bit_vector: ["0212fb0084"]
4444

4545
- do:
4646
indices.refresh: {}
@@ -115,7 +115,7 @@ setup:
115115
- match: {hits.hits.1._id: "3"}
116116
- close_to: {hits.hits.1._score: {value: 2, error: 0.01}}
117117

118-
# doing max-sim dot product with a vector where the stored bit vectors are used as masks
118+
# doing max-sim dot product with a vector where the stored bit vectors are used as masks
119119
- do:
120120
headers:
121121
Content-Type: application/json
@@ -179,6 +179,28 @@ setup:
179179
- match: {hits.hits.1._id: "1"}
180180
- close_to: {hits.hits.1._score: {value: 0.65, error: 0.01}}
181181

182+
- do:
183+
headers:
184+
Content-Type: application/json
185+
search:
186+
rest_total_hits_as_int: true
187+
body:
188+
query:
189+
script_score:
190+
query: {match_all: {} }
191+
script:
192+
source: "maxSimInvHamming(params.query_vector, 'byte_vector')"
193+
params:
194+
query_vector: ["0102010101"]
195+
196+
- match: {hits.total: 2}
197+
198+
- match: {hits.hits.0._id: "3"}
199+
- close_to: {hits.hits.0._score: {value: 0.675, error: 0.01}}
200+
201+
- match: {hits.hits.1._id: "1"}
202+
- close_to: {hits.hits.1._score: {value: 0.65, error: 0.01}}
203+
182204
- do:
183205
headers:
184206
Content-Type: application/json
@@ -200,3 +222,25 @@ setup:
200222

201223
- match: {hits.hits.1._id: "1"}
202224
- close_to: {hits.hits.1._score: {value: 0.65, error: 0.01}}
225+
226+
- do:
227+
headers:
228+
Content-Type: application/json
229+
search:
230+
rest_total_hits_as_int: true
231+
body:
232+
query:
233+
script_score:
234+
query: {match_all: {} }
235+
script:
236+
source: "maxSimInvHamming(params.query_vector, 'bit_vector')"
237+
params:
238+
query_vector: ["0102010101"]
239+
240+
- match: {hits.total: 2}
241+
242+
- match: {hits.hits.0._id: "3"}
243+
- close_to: {hits.hits.0._score: {value: 0.675, error: 0.01}}
244+
245+
- match: {hits.hits.1._id: "1"}
246+
- close_to: {hits.hits.1._score: {value: 0.65, error: 0.01}}

0 commit comments

Comments
 (0)