You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/query-languages/query-dsl/query-dsl-semantic-query.md
+11-1Lines changed: 11 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,8 +13,18 @@ applies_to:
13
13
We don't recommend this legacy query type for _new_ projects. Use the match query (with [QueryDSL](/reference/query-languages/query-dsl/query-dsl-match-query.md) or [ESQL](/reference/query-languages/esql/functions-operators/search-functions.md#esql-match)) instead. The semantic query remains available to support existing implementations.
14
14
::::
15
15
16
-
The `semantic` query type enables you to perform [semantic search](docs-content://solutions/search/semantic-search.md) on data stored in a [`semantic_text`](/reference/elasticsearch/mapping-reference/semantic-text.md) field.
16
+
The `semantic` query type enables you to perform [semantic search](docs-content://solutions/search/semantic-search.md) on data stored in a [`semantic_text`](/reference/elasticsearch/mapping-reference/semantic-text.md) field. This query accepts natural-language text and uses the field’s configured inference endpoint to generate a query embedding and match documents.
17
17
18
+
For an overview of all query options available for `semantic_text` fields, see [Querying `semantic_text` fields](/reference/elasticsearch/mapping-reference/semantic-text.md#querying-semantic-text-fields).
19
+
20
+
## Inference endpoint selection
21
+
22
+
The target field of `semantic` query must be mapped as `semantic_text` and associated with an inference endpoint. At query time, the inference endpoint is chosen as follows:
23
+
- If `search_inference_id` is defined, the semantic query uses that endpoint to embed the query.
24
+
- If no `search_inference_id` is defined, `inference_id` is used for both indexing and search.
25
+
- If no endpoint is specified at mapping, `inference_id` defaults to `.elser-2-elasticsearch`.
26
+
27
+
The underlying vector type (dense or sparse) is determined by the endpoint automatically. No extra query parameters are required.
Copy file name to clipboardExpand all lines: docs/reference/query-languages/query-dsl/query-dsl-sparse-vector-query.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -208,6 +208,54 @@ GET my-index/_search
208
208
```
209
209
% TEST[skip: Requires inference]
210
210
211
+
## Example query on a `semantic_text` field
212
+
213
+
You can also run a `sparse_vector` query directly on a [`semantic_text`](/reference/elasticsearch/mapping-reference/semantic-text.md) field. In this case Elasticsearch automatically uses the inference endpoint configured in the field mapping to expand the query into sparse tokens.
214
+
215
+
First, create an index with a `semantic_text` field:
0 commit comments