|
@@ -0,0 +1,165 @@
|
|
|
+setup:
|
|
|
+ - requires:
|
|
|
+ cluster_features: "mapper.vectors.bbq"
|
|
|
+ reason: 'kNN float to better-binary quantization is required'
|
|
|
+ - do:
|
|
|
+ indices.create:
|
|
|
+ index: bbq_flat
|
|
|
+ body:
|
|
|
+ settings:
|
|
|
+ index:
|
|
|
+ number_of_shards: 1
|
|
|
+ mappings:
|
|
|
+ properties:
|
|
|
+ name:
|
|
|
+ type: keyword
|
|
|
+ vector:
|
|
|
+ type: dense_vector
|
|
|
+ dims: 64
|
|
|
+ index: true
|
|
|
+ similarity: l2_norm
|
|
|
+ index_options:
|
|
|
+ type: bbq_flat
|
|
|
+ another_vector:
|
|
|
+ type: dense_vector
|
|
|
+ dims: 64
|
|
|
+ index: true
|
|
|
+ similarity: l2_norm
|
|
|
+ index_options:
|
|
|
+ type: bbq_flat
|
|
|
+
|
|
|
+ - do:
|
|
|
+ index:
|
|
|
+ index: bbq_flat
|
|
|
+ id: "1"
|
|
|
+ body:
|
|
|
+ name: cow.jpg
|
|
|
+ vector: [300.33, -34.8988, 15.555, -200.0, 230.0, 300.33, -34.8988, 15.555, -200.0, 230.0, 300.33, -34.8988, 15.555, -200.0, 230.0, 300.33, -34.8988, 15.555, -200.0, 230.0, 300.33, -34.8988, 15.555, -200.0, 230.0, 300.33, -34.8988, 15.555, -200.0, 230.0, 300.33, -34.8988, 15.555, -200.0, 230.0, 300.33, -34.8988, 15.555, -200.0, 230.0, 300.33, -34.8988, 15.555, -200.0, 230.0, 300.33, -34.8988, 15.555, -200.0, 230.0, 300.33, -34.8988, 15.555, -200.0, 230.0, 300.33, -34.8988, 15.555, -200.0, 230.0, 300.33, -34.8988, 15.555, -200.0]
|
|
|
+ another_vector: [115.0, -1.02, 15.555, -100.0, 130.0, 115.0, -1.02, 15.555, -100.0, 130.0, 115.0, -1.02, 15.555, -100.0, 130.0, 115.0, -1.02, 15.555, -100.0, 130.0, 115.0, -1.02, 15.555, -100.0, 130.0, 115.0, -1.02, 15.555, -100.0, 130.0, 115.0, -1.02, 15.555, -100.0, 130.0, 115.0, -1.02, 15.555, -100.0, 130.0, 115.0, -1.02, 15.555, -100.0, 130.0, 115.0, -1.02, 15.555, -100.0, 130.0, 115.0, -1.02, 15.555, -100.0, 130.0, 115.0, -1.02, 15.555, -100.0, 130.0, 115.0, -1.02, 15.555, -100.0]
|
|
|
+ # Flush in order to provoke a merge later
|
|
|
+ - do:
|
|
|
+ indices.flush:
|
|
|
+ index: bbq_flat
|
|
|
+
|
|
|
+ - do:
|
|
|
+ index:
|
|
|
+ index: bbq_flat
|
|
|
+ id: "2"
|
|
|
+ body:
|
|
|
+ name: moose.jpg
|
|
|
+ vector: [100.0, -13, 14.8, -156.0, -0.5, 100.0, -13, 14.8, -156.0, -0.5, 100.0, -13, 14.8, -156.0, -0.5, 100.0, -13, 14.8, -156.0, -0.5, 100.0, -13, 14.8, -156.0, -0.5, 100.0, -13, 14.8, -156.0, -0.5, 100.0, -13, 14.8, -156.0, -0.5, 100.0, -13, 14.8, -156.0, -0.5, 100.0, -13, 14.8, -156.0, -0.5, 100.0, -13, 14.8, -156.0, -0.5, 100.0, -13, 14.8, -156.0, -0.5, 100.0, -13, 14.8, -156.0, -0.5, 100.0, -13, 14.8, -156.0]
|
|
|
+ another_vector: [50.0, -1, 1, 120, -0.5, 50.0, -1, 1, 120, -0.5, 50.0, -1, 1, 120, -0.5, 50.0, -1, 1, 120, -0.5, 50.0, -1, 1, 120, -0.5, 50.0, -1, 1, 120, -0.5, 50.0, -1, 1, 120, -0.5, 50.0, -1, 1, 120, -0.5, 50.0, -1, 1, 120, -0.5, 50.0, -1, 1, 120, -0.5, 50.0, -1, 1, 120, -0.5, 50.0, -1, 1, 120, -0.5, 50.0, -1, 1, 120]
|
|
|
+ # Flush in order to provoke a merge later
|
|
|
+ - do:
|
|
|
+ indices.flush:
|
|
|
+ index: bbq_flat
|
|
|
+
|
|
|
+ - do:
|
|
|
+ index:
|
|
|
+ index: bbq_flat
|
|
|
+ id: "3"
|
|
|
+ body:
|
|
|
+ name: rabbit.jpg
|
|
|
+ vector: [111.3, -13.0, 14.8, -156.0, 0.5, 111.3, -13.0, 14.8, -156.0, 0.5, 111.3, -13.0, 14.8, -156.0, 0.5, 111.3, -13.0, 14.8, -156.0, 0.5, 111.3, -13.0, 14.8, -156.0, 0.5, 111.3, -13.0, 14.8, -156.0, 0.5, 111.3, -13.0, 14.8, -156.0, 0.5, 111.3, -13.0, 14.8, -156.0, 0.5, 111.3, -13.0, 14.8, -156.0, 0.5, 111.3, -13.0, 14.8, -156.0, 0.5, 111.3, -13.0, 14.8, -156.0, 0.5, 111.3, -13.0, 14.8, -156.0, 0.5, 111.3, -13.0, 14.8, -156.0]
|
|
|
+ another_vector: [11.0, 0, 12, 111.0, -0.5, 11.0, 0, 12, 111.0, -0.5, 11.0, 0, 12, 111.0, -0.5, 11.0, 0, 12, 111.0, -0.5, 11.0, 0, 12, 111.0, -0.5, 11.0, 0, 12, 111.0, -0.5, 11.0, 0, 12, 111.0, -0.5, 11.0, 0, 12, 111.0, -0.5, 11.0, 0, 12, 111.0, -0.5, 11.0, 0, 12, 111.0, -0.5, 11.0, 0, 12, 111.0, -0.5, 11.0, 0, 12, 111.0, -0.5, 11.0, 0, 12, 111.0]
|
|
|
+ # Flush in order to provoke a merge later
|
|
|
+ - do:
|
|
|
+ indices.flush:
|
|
|
+ index: bbq_flat
|
|
|
+
|
|
|
+ - do:
|
|
|
+ indices.forcemerge:
|
|
|
+ index: bbq_flat
|
|
|
+ max_num_segments: 1
|
|
|
+---
|
|
|
+"Test knn search":
|
|
|
+ - do:
|
|
|
+ search:
|
|
|
+ index: bbq_flat
|
|
|
+ body:
|
|
|
+ knn:
|
|
|
+ field: vector
|
|
|
+ query_vector: [ 90.0, -10, 14.8, -156.0, -0.5, 90.0, -10, 14.8, -156.0, -0.5, 90.0, -10, 14.8, -156.0, -0.5, 90.0, -10, 14.8, -156.0, -0.5, 90.0, -10, 14.8, -156.0, -0.5, 90.0, -10, 14.8, -156.0, -0.5, 90.0, -10, 14.8, -156.0, -0.5, 90.0, -10, 14.8, -156.0, -0.5, 90.0, -10, 14.8, -156.0, -0.5, 90.0, -10, 14.8, -156.0, -0.5, 90.0, -10, 14.8, -156.0, -0.5, 90.0, -10, 14.8, -156.0, -0.5, 90.0, -10, 14.8, -156.0]
|
|
|
+ k: 3
|
|
|
+ num_candidates: 3
|
|
|
+
|
|
|
+ # Depending on how things are distributed, docs 2 and 3 might be swapped
|
|
|
+ # here we verify that are last hit is always the worst one
|
|
|
+ - match: { hits.hits.2._id: "1" }
|
|
|
+---
|
|
|
+"Test bad parameters":
|
|
|
+ - do:
|
|
|
+ catch: bad_request
|
|
|
+ indices.create:
|
|
|
+ index: bad_bbq_flat
|
|
|
+ body:
|
|
|
+ mappings:
|
|
|
+ properties:
|
|
|
+ vector:
|
|
|
+ type: dense_vector
|
|
|
+ dims: 64
|
|
|
+ index: true
|
|
|
+ index_options:
|
|
|
+ type: bbq_flat
|
|
|
+ m: 42
|
|
|
+
|
|
|
+ - do:
|
|
|
+ catch: bad_request
|
|
|
+ indices.create:
|
|
|
+ index: bad_bbq_flat
|
|
|
+ body:
|
|
|
+ mappings:
|
|
|
+ properties:
|
|
|
+ vector:
|
|
|
+ type: dense_vector
|
|
|
+ dims: 64
|
|
|
+ element_type: byte
|
|
|
+ index: true
|
|
|
+ index_options:
|
|
|
+ type: bbq_flat
|
|
|
+---
|
|
|
+"Test few dimensions fail indexing":
|
|
|
+ # verify index creation fails
|
|
|
+ - do:
|
|
|
+ catch: bad_request
|
|
|
+ indices.create:
|
|
|
+ index: bad_bbq_flat
|
|
|
+ body:
|
|
|
+ mappings:
|
|
|
+ properties:
|
|
|
+ vector:
|
|
|
+ type: dense_vector
|
|
|
+ dims: 42
|
|
|
+ index: true
|
|
|
+ similarity: l2_norm
|
|
|
+ index_options:
|
|
|
+ type: bbq_flat
|
|
|
+
|
|
|
+ # verify dynamic dimension fails
|
|
|
+ - do:
|
|
|
+ indices.create:
|
|
|
+ index: dynamic_dim_bbq_flat
|
|
|
+ body:
|
|
|
+ mappings:
|
|
|
+ properties:
|
|
|
+ vector:
|
|
|
+ type: dense_vector
|
|
|
+ index: true
|
|
|
+ similarity: l2_norm
|
|
|
+ index_options:
|
|
|
+ type: bbq_flat
|
|
|
+
|
|
|
+ # verify index fails for odd dim vector
|
|
|
+ - do:
|
|
|
+ catch: bad_request
|
|
|
+ index:
|
|
|
+ index: dynamic_dim_bbq_flat
|
|
|
+ body:
|
|
|
+ vector: [1.0, 2.0, 3.0, 4.0, 5.0]
|
|
|
+
|
|
|
+ # verify that we can index an even dim vector after the odd dim vector failure
|
|
|
+ - do:
|
|
|
+ index:
|
|
|
+ index: dynamic_dim_bbq_flat
|
|
|
+ body:
|
|
|
+ vector: [1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 3.0, 4.0]
|