File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -274,6 +274,36 @@ A sample query can look like below:
274274----
275275// NOTCONSOLE
276276
277+ [[knn-query-with-semantic-text]]
278+ ==== Knn query on a semantic_text field
279+
280+ Elasticsearch supports `knn` query over a <<semantic-text, semantic_text>> field.
281+
282+ Here is an example using the `query_vector_builder`:
283+
284+ [source,js]
285+ ----
286+ {
287+ "query": {
288+ "knn": {
289+ "field": "inference_field",
290+ "k": 10,
291+ "num_candidates": 100,
292+ "query_vector_builder": {
293+ "text_embedding": {
294+ "model_text": "test"
295+ }
296+ }
297+ }
298+ }
299+ }
300+ ----
301+ // NOTCONSOLE
302+
303+ Note that for `semantic_text` fields, the `model_id` does not have to be provided as it can be inferred from the `semantic_text` field mapping.
304+
305+ Knn search using query vectors over `semantic_text` fields is also supported, with no change to the API.
306+
277307[[knn-query-aggregations]]
278308==== Knn query with aggregations
279309`knn` query calculates aggregations on top `k` documents from each shard.
You can’t perform that action at this time.
0 commit comments