@@ -107,6 +107,38 @@ setup:
107107 - match : {hits.hits.2._id: "1"}
108108 - match : {hits.hits.2._score: 1632.0}
109109---
110+ " Dot Product float " :
111+ - requires :
112+ capabilities :
113+ - path : /_search
114+ capabilities : [byte_float_dot_product_capability]
115+ test_runner_features : [capabilities]
116+ reason : " float vector queries capability added"
117+ - do :
118+ headers :
119+ Content-Type : application/json
120+ search :
121+ rest_total_hits_as_int : true
122+ body :
123+ query :
124+ script_score :
125+ query : {match_all: {} }
126+ script :
127+ source : " dotProduct(params.query_vector, 'vector')"
128+ params :
129+ query_vector : [0.0, 111.0, -13.0, 14.0, -124.0]
130+
131+ - match : {hits.total: 3}
132+
133+ - match : {hits.hits.0._id: "2"}
134+ - match : {hits.hits.0._score: 28732.0}
135+
136+ - match : {hits.hits.1._id: "3"}
137+ - match : {hits.hits.1._score: 17439.0}
138+
139+ - match : {hits.hits.2._id: "1"}
140+ - match : {hits.hits.2._score: 1632.0}
141+ ---
110142" Cosine Similarity " :
111143 - do :
112144 headers :
@@ -198,3 +230,39 @@ setup:
198230 - match : {hits.hits.2._id: "1"}
199231 - gte : {hits.hits.2._score: 0.509}
200232 - lte : {hits.hits.2._score: 0.512}
233+
234+ ---
235+ " Cosine Similarity float " :
236+ - requires :
237+ capabilities :
238+ - path : /_search
239+ capabilities : [byte_float_dot_product_capability]
240+ test_runner_features : [capabilities]
241+ reason : " float vector queries capability added"
242+ - do :
243+ headers :
244+ Content-Type : application/json
245+ search :
246+ rest_total_hits_as_int : true
247+ body :
248+ query :
249+ script_score :
250+ query : {match_all: {} }
251+ script :
252+ source : " cosineSimilarity(params.query_vector, 'vector')"
253+ params :
254+ query_vector : [0.0, 111.0, -13.0, 14.0, -124.0]
255+
256+ - match : {hits.total: 3}
257+
258+ - match : {hits.hits.0._id: "2"}
259+ - gte : {hits.hits.0._score: 0.995}
260+ - lte : {hits.hits.0._score: 0.998}
261+
262+ - match : {hits.hits.1._id: "3"}
263+ - gte : {hits.hits.1._score: 0.829}
264+ - lte : {hits.hits.1._score: 0.832}
265+
266+ - match : {hits.hits.2._id: "1"}
267+ - gte : {hits.hits.2._score: 0.509}
268+ - lte : {hits.hits.2._score: 0.512}
0 commit comments