mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-06-28 09:28:55 -04:00
Update docs for knn query on semantic_text fields (#130193)
This commit is contained in:
parent
04dee4637e
commit
23b624232f
1 changed files with 30 additions and 0 deletions
|
@ -274,6 +274,36 @@ A sample query can look like below:
|
|||
----
|
||||
// NOTCONSOLE
|
||||
|
||||
[[knn-query-with-semantic-text]]
|
||||
==== Knn query on a semantic_text field
|
||||
|
||||
Elasticsearch supports `knn` query over a <<semantic-text, semantic_text>> field.
|
||||
|
||||
Here is an example using the `query_vector_builder`:
|
||||
|
||||
[source,js]
|
||||
----
|
||||
{
|
||||
"query": {
|
||||
"knn": {
|
||||
"field": "inference_field",
|
||||
"k": 10,
|
||||
"num_candidates": 100,
|
||||
"query_vector_builder": {
|
||||
"text_embedding": {
|
||||
"model_text": "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
----
|
||||
// NOTCONSOLE
|
||||
|
||||
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.
|
||||
|
||||
Knn search using query vectors over `semantic_text` fields is also supported, with no change to the API.
|
||||
|
||||
[[knn-query-aggregations]]
|
||||
==== Knn query with aggregations
|
||||
`knn` query calculates aggregations on top `k` documents from each shard.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue