Skip to content

Commit dc0012c

Browse files
Adjust docs
1 parent 348305f commit dc0012c

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

docs/reference/query-dsl/knn-query.asciidoc

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ expert cases, where there is a need to combine this query with other queries.
1515

1616
[source,console]
1717
----
18-
PUT image-index
18+
PUT my-image-index
1919
{
2020
"mappings": {
2121
"properties": {
@@ -25,15 +25,6 @@ PUT image-index
2525
"index": true,
2626
"similarity": "l2_norm"
2727
},
28-
"title-vector": {
29-
"type": "dense_vector",
30-
"dims": 5,
31-
"index": true,
32-
"similarity": "l2_norm"
33-
},
34-
"title": {
35-
"type": "text"
36-
},
3728
"file-type": {
3829
"type": "keyword"
3930
}
@@ -47,23 +38,21 @@ PUT image-index
4738
+
4839
[source,console]
4940
----
50-
POST image-index/_bulk?refresh=true
41+
POST my-image-index/_bulk?refresh=true
5142
{ "index": { "_id": "1" } }
52-
{ "image-vector": [1, 5, -20], "title-vector": [12, 50, -10, 0, 1], "title": "moose family", "file-type": "jpg" }
43+
{ "image-vector": [1, 5, -20], "file-type": "jpg" }
5344
{ "index": { "_id": "2" } }
54-
{ "image-vector": [42, 8, -15], "title-vector": [25, 1, 4, -12, 2], "title": "alpine lake", "file-type": "png" }
45+
{ "image-vector": [42, 8, -15], "file-type": "png" }
5546
{ "index": { "_id": "3" } }
56-
{ "image-vector": [15, 11, 23], "title-vector": [1, 5, 25, 50, 20], "title": "full moon", "file-type": "jpg" }
57-
...
47+
{ "image-vector": [15, 11, 23], "file-type": "jpg" }
5848
----
5949
//TEST[continued]
60-
//TEST[s/\.\.\.//]
6150

6251
. Run the search using the `knn` query, asking for the top 3 nearest vectors.
6352
+
6453
[source,console]
6554
----
66-
POST image-index/_search
55+
POST my-image-index/_search
6756
{
6857
"size" : 3,
6958
"query" : {
@@ -72,8 +61,7 @@ POST image-index/_search
7261
"query_vector": [-5, 9, -12],
7362
"num_candidates": 10
7463
}
75-
},
76-
"fields": [ "title", "file-type" ]
64+
}
7765
}
7866
----
7967
//TEST[continued]
@@ -168,7 +156,7 @@ that passes the post-filter.
168156

169157
[source,console]
170158
----
171-
POST image-index/_search
159+
POST my-image-index/_search
172160
{
173161
"size" : 10,
174162
"query" : {
@@ -184,8 +172,7 @@ POST image-index/_search
184172
"term" : { "file-type" : "png" }
185173
}
186174
}
187-
},
188-
"fields": [ "title", "file-type" ]
175+
}
189176
}
190177
----
191178
//TEST[continued]

0 commit comments

Comments
 (0)