-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathknn_search.yml
81 lines (79 loc) · 1.91 KB
/
knn_search.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
---
requires:
serverless: false
stack: true
---
setup:
- do:
indices.create:
index: knn_test
body:
mappings:
properties:
name:
type: keyword
vector:
type: dense_vector
dims: 5
index: true
similarity: l2_norm
index_options:
type: hnsw
m: 16
ef_construction: 200
another_vector:
type: dense_vector
dims: 5
index: true
similarity: l2_norm
index_options:
type: hnsw
m: 16
ef_construction: 200
- do:
index:
index: knn_test
id: "1"
body:
name: cow.jpg
vector: [230.0, 300.33, -34.8988, 15.555, -200.0]
another_vector: [130.0, 115.0, -1.02, 15.555, -100.0]
- do:
index:
index: knn_test
id: "2"
body:
name: moose.jpg
vector: [-0.5, 100.0, -13, 14.8, -156.0]
another_vector: [-0.5, 50.0, -1, 1, 120]
- do:
index:
index: knn_test
id: "3"
body:
name: rabbit.jpg
vector: [0.5, 111.3, -13.0, 14.8, -156.0]
another_vector: [-0.5, 11.0, 0, 12, 111.0]
- do:
indices.refresh: {}
---
teardown:
- do:
indices.delete:
index: knn_test
---
"kNN search in _knn_search endpoint":
- do:
knn_search:
index: knn_test
body:
fields: [ "name" ]
knn:
field: vector
query_vector: [-0.5, 90.0, -10, 14.8, -156.0]
k: 2
num_candidates: 3
- match: {hits.hits.0._id: "2"}
- match: {hits.hits.0.fields.name.0: "moose.jpg"}
- match: {hits.hits.1._id: "3"}
- match: {hits.hits.1.fields.name.0: "rabbit.jpg"}