Skip to content

Commit d90d435

Browse files
authored
[SEARCH] Adds EIS scenario to semantic search tutorial (#3146)
# [PAGE PREVIEW](https://docs-v3-preview.elastic.dev/elastic/docs-content/pull/3146/solutions/search/semantic-search/semantic-search-semantic-text#semantic-text-index-mapping) ## Overview Related issue: elastic/search-team#10758 and #3008 **Do not merge until EIS is the default inference endpoint for semantic text on serverless (ETA late October)** This PR updates the `Semantic search with semantic_text` tutorial to show how to use inference endpoints on EIS. It separates the behavior for Serverless and Cloud. From mid-October, EIS will be the default for `semantic_text` on Serverless, but on Cloud, it won’t become the default until January. Until then, the two cases need to be documented separately.
1 parent 392d3ab commit d90d435

File tree

1 file changed

+65
-7
lines changed

1 file changed

+65
-7
lines changed

solutions/search/semantic-search/semantic-search-semantic-text.md

Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ This tutorial uses the `elasticsearch` service for demonstration, which is creat
2727

2828
The mapping of the destination index - the index that contains the embeddings that the inference endpoint will generate based on your input text - must be created. The destination index must have a field with the [`semantic_text`](elasticsearch://reference/elasticsearch/mapping-reference/semantic-text.md) field type to index the output of the used inference endpoint.
2929

30+
You can run {{infer}} either using the [Elastic {{infer-cap}} Service](/explore-analyze/elastic-inference/eis.md) or on your own ML-nodes. The following examples show you both scenarios.
31+
32+
:::::::{tab-set}
33+
34+
::::::{tab-item} Using EIS on Serverless
35+
36+
```{applies_to}
37+
serverless: ga
38+
```
39+
3040
```console
3141
PUT semantic-embeddings
3242
{
@@ -41,7 +51,61 @@ PUT semantic-embeddings
4151
```
4252

4353
1. The name of the field to contain the generated embeddings.
44-
2. The field to contain the embeddings is a `semantic_text` field. Since no `inference_id` is provided, the default endpoint `.elser-2-elasticsearch` for the `elasticsearch` service is used. To use a different {{infer}} service, you must create an {{infer}} endpoint first using the [Create {{infer}} API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put) and then specify it in the `semantic_text` field mapping using the `inference_id` parameter.
54+
2. The field to contain the embeddings is a `semantic_text` field. Since no `inference_id` is provided, the default endpoint `.elser-v2-elastic` for the `elasticsearch` service is used. This {{infer}} endpoint uses the [Elastic {{infer-cap}} Service (EIS)](/explore-analyze/elastic-inference/eis.md).
55+
56+
::::::
57+
58+
::::::{tab-item} Using EIS in Cloud
59+
60+
```{applies_to}
61+
stack: ga
62+
deployment:
63+
self: unavailable
64+
```
65+
66+
```console
67+
PUT semantic-embeddings
68+
{
69+
"mappings": {
70+
"properties": {
71+
"content": { <1>
72+
"type": "semantic_text", <2>
73+
"inference_id": ".elser-v2-elastic" <3>
74+
}
75+
}
76+
}
77+
}
78+
```
79+
80+
1. The name of the field to contain the generated embeddings.
81+
2. The field to contain the embeddings is a `semantic_text` field.
82+
3. The `.elser-v2-elastic` preconfigured {{infer}} endpoint for the `elasticsearch` service is used. This {{infer}} endpoint uses the [Elastic {{infer-cap}} Service (EIS)](/explore-analyze/elastic-inference/eis.md).
83+
84+
::::::
85+
86+
::::::{tab-item} Using ML-nodes
87+
88+
```console
89+
PUT semantic-embeddings
90+
{
91+
"mappings": {
92+
"properties": {
93+
"content": { <1>
94+
"type": "semantic_text", <2>
95+
"inference_id": ".elser-2-elasticsearch" <3>
96+
}
97+
}
98+
}
99+
}
100+
```
101+
102+
1. The name of the field to contain the generated embeddings.
103+
2. The field to contain the embeddings is a `semantic_text` field.
104+
3. The `.elser-2-elasticsearch` preconfigured {{infer}} endpoint for the `elasticsearch` service is used. To use a different {{infer}} service, you must create an {{infer}} endpoint first using the [Create {{infer}} API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put) and then specify it in the `semantic_text` field mapping using the `inference_id` parameter.
105+
106+
::::::
107+
108+
:::::::
45109

46110
To try the ELSER model on the Elastic Inference Service, explicitly set the `inference_id` to `.elser-2-elastic`. For instructions, refer to [Using `semantic_text` with ELSER on EIS](https://www.elastic.co/docs/reference/elasticsearch/mapping-reference/semantic-text#using-elser-on-eis).
47111

@@ -50,8 +114,6 @@ If you’re using web crawlers or connectors to generate indices, you have to [u
50114

51115
::::
52116

53-
54-
55117
## Load data [semantic-text-load-data]
56118

57119
In this step, you load the data that you later use to create embeddings from it.
@@ -60,7 +122,6 @@ Use the `msmarco-passagetest2019-top1000` data set, which is a subset of the MS
60122

61123
Download the file and upload it to your cluster using the [Data Visualizer](../../../manage-data/ingest/upload-data-files.md) in the {{ml-app}} UI. After your data is analyzed, click **Override settings**. Under **Edit field names**, assign `id` to the first column and `content` to the second. Click **Apply**, then **Import**. Name the index `test-data`, and click **Import**. After the upload is complete, you will see an index named `test-data` with 182,469 documents.
62124

63-
64125
## Reindex the data [semantic-text-reindex-data]
65126

66127
Create the embeddings from the text by reindexing the data from the `test-data` index to the `semantic-embeddings` index. The data in the `content` field will be reindexed into the `content` semantic text field of the destination index. The reindexed data will be processed by the {{infer}} endpoint associated with the `content` semantic text field.
@@ -70,7 +131,6 @@ This step uses the reindex API to simulate data ingestion. If you are working wi
70131

71132
::::
72133

73-
74134
```console
75135
POST _reindex?wait_for_completion=false
76136
{
@@ -86,7 +146,6 @@ POST _reindex?wait_for_completion=false
86146

87147
1. The default batch size for reindexing is 1000. Reducing size to a smaller number makes the update of the reindexing process quicker which enables you to follow the progress closely and detect errors early.
88148

89-
90149
The call returns a task ID to monitor the progress:
91150

92151
```console
@@ -99,7 +158,6 @@ Reindexing large datasets can take a long time. You can test this workflow using
99158
POST _tasks/<task_id>/_cancel
100159
```
101160

102-
103161
## Semantic search [semantic-text-semantic-search]
104162

105163
After the data has been indexed with the embeddings, you can query the data using semantic search. Choose between [Query DSL](/explore-analyze/query-filter/languages/querydsl.md) or [{{esql}}](elasticsearch://reference/query-languages/esql.md) syntax to execute the query.

0 commit comments

Comments
 (0)