Skip to content

Commit 5b5c997

Browse files
committed
add yaml test
1 parent 0efd8d9 commit 5b5c997

File tree

1 file changed

+166
-0
lines changed

1 file changed

+166
-0
lines changed
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
setup:
2+
- requires:
3+
cluster_features: [ "search.vectors.mappers.expose_hnsw_early_termination" ]
4+
reason: "requires early termination for hnsw to be exposed"
5+
- do:
6+
indices.create:
7+
index: bbq_hnsw
8+
body:
9+
settings:
10+
index:
11+
number_of_shards: 1
12+
mappings:
13+
properties:
14+
vector:
15+
type: dense_vector
16+
dims: 64
17+
index: true
18+
similarity: dot_product
19+
index_options:
20+
type: bbq_hnsw
21+
early_termination: true
22+
23+
- do:
24+
index:
25+
index: bbq_hnsw
26+
id: "1"
27+
body:
28+
vector: [0.077, 0.32 , -0.205, 0.63 , 0.032, 0.201, 0.167, -0.313,
29+
0.176, 0.531, -0.375, 0.334, -0.046, 0.078, -0.349, 0.272,
30+
0.307, -0.083, 0.504, 0.255, -0.404, 0.289, -0.226, -0.132,
31+
-0.216, 0.49 , 0.039, 0.507, -0.307, 0.107, 0.09 , -0.265,
32+
-0.285, 0.336, -0.272, 0.369, -0.282, 0.086, -0.132, 0.475,
33+
-0.224, 0.203, 0.439, 0.064, 0.246, -0.396, 0.297, 0.242,
34+
-0.028, 0.321, -0.022, -0.009, -0.001 , 0.031, -0.533, 0.45,
35+
-0.683, 1.331, 0.194, -0.157, -0.1 , -0.279, -0.098, -0.176]
36+
- do:
37+
index:
38+
index: bbq_hnsw
39+
id: "2"
40+
body:
41+
vector: [0.196, 0.514, 0.039, 0.555, -0.042, 0.242, 0.463, -0.348,
42+
-0.08 , 0.442, -0.067, -0.05 , -0.001, 0.298, -0.377, 0.048,
43+
0.307, 0.159, 0.278, 0.119, -0.057, 0.333, -0.289, -0.438,
44+
-0.014, 0.361, -0.169, 0.292, -0.229, 0.123, 0.031, -0.138,
45+
-0.139, 0.315, -0.216, 0.322, -0.445, -0.059, 0.071, 0.429,
46+
-0.602, -0.142, 0.11 , 0.192, 0.259, -0.241, 0.181, -0.166,
47+
0.082, 0.107, -0.05 , 0.155, 0.011, 0.161, -0.486, 0.569,
48+
-0.489, 0.901, 0.208, 0.011, -0.209, -0.153, -0.27 , -0.013]
49+
50+
- do:
51+
index:
52+
index: bbq_hnsw
53+
id: "3"
54+
body:
55+
name: rabbit.jpg
56+
vector: [0.139, 0.178, -0.117, 0.399, 0.014, -0.139, 0.347, -0.33 ,
57+
0.139, 0.34 , -0.052, -0.052, -0.249, 0.327, -0.288, 0.049,
58+
0.464, 0.338, 0.516, 0.247, -0.104, 0.259, -0.209, -0.246,
59+
-0.11 , 0.323, 0.091, 0.442, -0.254, 0.195, -0.109, -0.058,
60+
-0.279, 0.402, -0.107, 0.308, -0.273, 0.019, 0.082, 0.399,
61+
-0.658, -0.03 , 0.276, 0.041, 0.187, -0.331, 0.165, 0.017,
62+
0.171, -0.203, -0.198, 0.115, -0.007, 0.337, -0.444, 0.615,
63+
-0.657, 1.285, 0.2 , -0.062, 0.038, 0.089, -0.068, -0.058]
64+
- do:
65+
index:
66+
index: bbq_hnsw
67+
id: "4"
68+
body:
69+
vector: [ 0.123, 0.32 , -0.205, -0.63 , 0.132, 0.201, 0.167, -0.313,
70+
0.176, 0.531, -0.375, 0.334, -0.046, 0.078, -0.349, 0.272,
71+
0.307, -0.083, 0.504, 0.255, -0.904, 0.289, -0.226, -0.132,
72+
-0.216, 0.49 , 0.039, 0.507, -0.307, 0.107, 0.09 , -0.265,
73+
-0.285, 0.336, -0.272, 0.161, -0.282, 0.086, -0.132, 0.475,
74+
-0.224, 0.203, 0.439, 0.064, 0.246, -0.396, 0.297, 0.242,
75+
-0.028, 0.321, -0.032, -0.009, -0.001 , 0.031, -0.533, 0.45,
76+
-0.683, 1.331, 0.294, -0.157, -0.1 , -0.279, -0.098, -0.176 ]
77+
78+
- do:
79+
index:
80+
index: bbq_hnsw
81+
id: "5"
82+
body:
83+
vector: [ 0.456, 0.32 , -0.205, 0.63 , 0.032, 0.201, 0.167, -0.313,
84+
0.176, 0.531, -0.375, 0.334, -0.103, 0.078, -0.488, 0.272,
85+
0.307, -0.083, 0.504, 0.255, -0.404, 0.289, -0.226, -0.132,
86+
-0.216, 0.49 , 0.039, 0.507, -0.307, 0.107, 0.084 , -0.093,
87+
-0.285, 0.336, -0.272, 0.369, -0.743, 0.086, -0.132, 0.475,
88+
-0.224, 0.203, -0.439, 0.064, 0.246, -0.396, 0.297, 0.242,
89+
-0.028, 0.321, -0.022, -0.009, -0.001 , 0.031, -0.533, 0.45,
90+
-0.683, 1.331, 0.194, -0.157, -0.1 , -0.279, -0.098, -0.789 ]
91+
# Flush in order to provoke a merge later
92+
- do:
93+
indices.flush:
94+
index: bbq_hnsw
95+
96+
---
97+
"Run knn search with early termination":
98+
99+
- do:
100+
search:
101+
index: bbq_hnsw
102+
body:
103+
profile: true
104+
knn:
105+
field: vector
106+
query_vector: [0.128, 0.067, -0.08 , 0.395, -0.11 , -0.259, 0.473, -0.393,
107+
0.292, 0.571, -0.491, 0.444, -0.288, 0.198, -0.343, 0.015,
108+
0.232, 0.088, 0.228, 0.151, -0.136, 0.236, -0.273, -0.259,
109+
-0.217, 0.359, -0.207, 0.352, -0.142, 0.192, -0.061, -0.17 ,
110+
-0.343, 0.189, -0.221, 0.32 , -0.301, -0.1 , 0.005, 0.232,
111+
-0.344, 0.136, 0.252, 0.157, -0.13 , -0.244, 0.193, -0.034,
112+
-0.12 , -0.193, -0.102, 0.252, -0.185, -0.167, -0.575, 0.582,
113+
-0.426, 0.983, 0.212, 0.204, 0.03 , -0.276, -0.425, -0.158]
114+
k: 3
115+
num_candidates: 3
116+
117+
- match: { hits.total.value: 5 } # collector sees k docs
118+
- length: { hits.hits: 3 } # size docs retrieved
119+
- match: { hits.hits.0._id: "1" }
120+
- match: { hits.hits.1._id: "2" }
121+
- match: { hits.hits.2._id: "3" }
122+
123+
---
124+
"Profile knn search with early termination":
125+
126+
- do:
127+
search:
128+
index: bbq_hnsw
129+
body:
130+
profile: true
131+
knn:
132+
field: vector
133+
query_vector: [0.128, 0.067, -0.08 , 0.395, -0.11 , -0.259, 0.473, -0.393,
134+
0.292, 0.571, -0.491, 0.444, -0.288, 0.198, -0.343, 0.015,
135+
0.232, 0.088, 0.228, 0.151, -0.136, 0.236, -0.273, -0.259,
136+
-0.217, 0.359, -0.207, 0.352, -0.142, 0.192, -0.061, -0.17 ,
137+
-0.343, 0.189, -0.221, 0.32 , -0.301, -0.1 , 0.005, 0.232,
138+
-0.344, 0.136, 0.252, 0.157, -0.13 , -0.244, 0.193, -0.034,
139+
-0.12 , -0.193, -0.102, 0.252, -0.185, -0.167, -0.575, 0.582,
140+
-0.426, 0.983, 0.212, 0.204, 0.03 , -0.276, -0.425, -0.158]
141+
k: 3
142+
num_candidates: 3
143+
144+
- match: { profile.shards.0.dfs.knn.0.vector_operations_count: 6 }
145+
146+
# Search with similarity to check number of operations are propagated correctly
147+
- do:
148+
search:
149+
index: bbq_hnsw
150+
body:
151+
profile: true
152+
knn:
153+
field: vector
154+
query_vector: [0.128, 0.067, -0.08 , 0.395, -0.11 , -0.259, 0.473, -0.393,
155+
0.292, 0.571, -0.491, 0.444, -0.288, 0.198, -0.343, 0.015,
156+
0.232, 0.088, 0.228, 0.151, -0.136, 0.236, -0.273, -0.259,
157+
-0.217, 0.359, -0.207, 0.352, -0.142, 0.192, -0.061, -0.17 ,
158+
-0.343, 0.189, -0.221, 0.32 , -0.301, -0.1 , 0.005, 0.232,
159+
-0.344, 0.136, 0.252, 0.157, -0.13 , -0.244, 0.193, -0.034,
160+
-0.12 , -0.193, -0.102, 0.252, -0.185, -0.167, -0.575, 0.582,
161+
-0.426, 0.983, 0.212, 0.204, 0.03 , -0.276, -0.425, -0.158]
162+
k: 3
163+
num_candidates: 3
164+
similarity: 100000
165+
166+
- match: { profile.shards.0.dfs.knn.0.vector_operations_count: 6 }

0 commit comments

Comments
 (0)