Skip to content

Commit 6c9b1f0

Browse files
authored
Semantic Text - Add YAML tests for inference metadata fields format (#118841)
1 parent f66f5bb commit 6c9b1f0

11 files changed

+2766
-964
lines changed

muted-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ tests:
148148
- class: org.elasticsearch.xpack.inference.InferenceRestIT
149149
method: test {p0=inference/30_semantic_text_inference/Calculates embeddings using the default ELSER 2 endpoint}
150150
issue: https://github.com/elastic/elasticsearch/issues/117349
151+
- class: org.elasticsearch.xpack.inference.InferenceRestIT
152+
method: test {p0=inference/30_semantic_text_inference_bwc/Calculates embeddings using the default ELSER 2 endpoint}
153+
issue: https://github.com/elastic/elasticsearch/issues/117349
151154
- class: org.elasticsearch.xpack.test.rest.XPackRestIT
152155
method: test {p0=transform/transforms_reset/Test reset running transform}
153156
issue: https://github.com/elastic/elasticsearch/issues/117473

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/rest/RestGetInferenceModelAction.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
@ServerlessScope(Scope.PUBLIC)
2929
public class RestGetInferenceModelAction extends BaseRestHandler {
3030
public static final String DEFAULT_ELSER_2_CAPABILITY = "default_elser_2";
31-
public static final String INFERENCE_METADATA_FIELDS_CAPABILITY = "inference_metadata_fields";
3231

3332
@Override
3433
public String getName() {
@@ -67,6 +66,6 @@ protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient
6766

6867
@Override
6968
public Set<String> supportedCapabilities() {
70-
return Set.of(DEFAULT_ELSER_2_CAPABILITY, INFERENCE_METADATA_FIELDS_CAPABILITY);
69+
return Set.of(DEFAULT_ELSER_2_CAPABILITY);
7170
}
7271
}

x-pack/plugin/inference/src/yamlRestTest/resources/rest-api-spec/test/inference/10_semantic_text_field_mapping.yml

Lines changed: 57 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ setup:
77
indices.create:
88
index: test-index
99
body:
10+
settings:
11+
index:
12+
mapping:
13+
semantic_text:
14+
use_legacy_format: false
1015
mappings:
1116
properties:
1217
sparse_field:
@@ -18,16 +23,6 @@ setup:
1823

1924
---
2025
"Indexes sparse vector document":
21-
- requires:
22-
test_runner_features: [capabilities]
23-
24-
- skip:
25-
reason: Test targets semantic text without inference metadata fields
26-
capabilities:
27-
- method: GET
28-
path: /_inference
29-
capabilities: [inference_metadata_fields]
30-
3126
# Checks mapping is not updated until first doc arrives
3227
- do:
3328
indices.get_mapping:
@@ -42,25 +37,28 @@ setup:
4237
index: test-index
4338
id: doc_1
4439
body:
45-
sparse_field:
46-
text: "these are not the droids you're looking for. He's free to go around"
40+
sparse_field: "these are not the droids you're looking for. He's free to go around"
41+
_inference_fields.sparse_field:
4742
inference:
4843
inference_id: sparse-inference-id
4944
model_settings:
5045
task_type: sparse_embedding
5146
chunks:
52-
- text: "these are not the droids you're looking for"
53-
embeddings:
54-
feature_0: 1.0
55-
feature_1: 2.0
56-
feature_2: 3.0
57-
feature_3: 4.0
58-
- text: "He's free to go around"
59-
embeddings:
60-
feature_4: 0.1
61-
feature_5: 0.2
62-
feature_6: 0.3
63-
feature_7: 0.4
47+
sparse_field:
48+
- start_offset: 0
49+
end_offset: 44
50+
embeddings:
51+
feature_0: 1.0
52+
feature_1: 2.0
53+
feature_2: 3.0
54+
feature_3: 4.0
55+
- start_offset: 44
56+
end_offset: 67
57+
embeddings:
58+
feature_4: 0.1
59+
feature_5: 0.2
60+
feature_6: 0.3
61+
feature_7: 0.4
6462

6563
# Checks mapping is updated when first doc arrives
6664
- do:
@@ -77,14 +75,6 @@ setup:
7775
- requires:
7876
cluster_features: "gte_v8.16.0"
7977
reason: field_caps support for semantic_text added in 8.16.0
80-
test_runner_features: [ capabilities ]
81-
82-
- skip:
83-
reason: Test targets semantic text without inference metadata fields
84-
capabilities:
85-
- method: GET
86-
path: /_inference
87-
capabilities: [ inference_metadata_fields ]
8878

8979
- do:
9080
field_caps:
@@ -111,25 +101,28 @@ setup:
111101
index: test-index
112102
id: doc_1
113103
body:
114-
sparse_field:
115-
text: "these are not the droids you're looking for. He's free to go around"
104+
sparse_field: "these are not the droids you're looking for. He's free to go around"
105+
_inference_fields.sparse_field:
116106
inference:
117107
inference_id: sparse-inference-id
118108
model_settings:
119109
task_type: sparse_embedding
120110
chunks:
121-
- text: "these are not the droids you're looking for"
122-
embeddings:
123-
feature_0: 1.0
124-
feature_1: 2.0
125-
feature_2: 3.0
126-
feature_3: 4.0
127-
- text: "He's free to go around"
128-
embeddings:
129-
feature_4: 0.1
130-
feature_5: 0.2
131-
feature_6: 0.3
132-
feature_7: 0.4
111+
sparse_field:
112+
- start_offset: 0
113+
end_offset: 44
114+
embeddings:
115+
feature_0: 1.0
116+
feature_1: 2.0
117+
feature_2: 3.0
118+
feature_3: 4.0
119+
- start_offset: 44
120+
end_offset: 67
121+
embeddings:
122+
feature_4: 0.1
123+
feature_5: 0.2
124+
feature_6: 0.3
125+
feature_7: 0.4
133126
refresh: true
134127

135128
- do:
@@ -157,16 +150,6 @@ setup:
157150

158151
---
159152
"Indexes dense vector document":
160-
- requires:
161-
test_runner_features: [ capabilities ]
162-
163-
- skip:
164-
reason: Test targets semantic text without inference metadata fields
165-
capabilities:
166-
- method: GET
167-
path: /_inference
168-
capabilities: [ inference_metadata_fields ]
169-
170153
# Checks mapping is not updated until first doc arrives
171154
- do:
172155
indices.get_mapping:
@@ -181,8 +164,8 @@ setup:
181164
index: test-index
182165
id: doc_2
183166
body:
184-
dense_field:
185-
text: "these are not the droids you're looking for. He's free to go around"
167+
dense_field: "these are not the droids you're looking for. He's free to go around"
168+
_inference_fields.dense_field:
186169
inference:
187170
inference_id: dense-inference-id
188171
model_settings:
@@ -191,10 +174,13 @@ setup:
191174
similarity: cosine
192175
element_type: float
193176
chunks:
194-
- text: "these are not the droids you're looking for"
195-
embeddings: [0.04673296958208084, -0.03237321600317955, -0.02543032355606556, 0.056035321205854416]
196-
- text: "He's free to go around"
197-
embeddings: [0.00641461368650198, -0.0016253676731139421, -0.05126338079571724, 0.053438711911439896]
177+
dense_field:
178+
- start_offset: 0
179+
end_offset: 44
180+
embeddings: [0.04673296958208084, -0.03237321600317955, -0.02543032355606556, 0.056035321205854416]
181+
- start_offset: 44
182+
end_offset: 67
183+
embeddings: [0.00641461368650198, -0.0016253676731139421, -0.05126338079571724, 0.053438711911439896]
198184

199185
# Checks mapping is updated when first doc arrives
200186
- do:
@@ -211,14 +197,6 @@ setup:
211197
- requires:
212198
cluster_features: "gte_v8.16.0"
213199
reason: field_caps support for semantic_text added in 8.16.0
214-
test_runner_features: [ capabilities ]
215-
216-
- skip:
217-
reason: Test targets semantic text without inference metadata fields
218-
capabilities:
219-
- method: GET
220-
path: /_inference
221-
capabilities: [ inference_metadata_fields ]
222200

223201
- do:
224202
field_caps:
@@ -245,8 +223,8 @@ setup:
245223
index: test-index
246224
id: doc_2
247225
body:
248-
dense_field:
249-
text: "these are not the droids you're looking for. He's free to go around"
226+
dense_field: "these are not the droids you're looking for. He's free to go around"
227+
_inference_fields.dense_field:
250228
inference:
251229
inference_id: dense-inference-id
252230
model_settings:
@@ -255,10 +233,13 @@ setup:
255233
similarity: cosine
256234
element_type: float
257235
chunks:
258-
- text: "these are not the droids you're looking for"
259-
embeddings: [ 0.04673296958208084, -0.03237321600317955, -0.02543032355606556, 0.056035321205854416 ]
260-
- text: "He's free to go around"
261-
embeddings: [ 0.00641461368650198, -0.0016253676731139421, -0.05126338079571724, 0.053438711911439896 ]
236+
dense_field:
237+
- start_offset: 0
238+
end_offset: 44
239+
embeddings: [0.04673296958208084, -0.03237321600317955, -0.02543032355606556, 0.056035321205854416]
240+
- start_offset: 44
241+
end_offset: 67
242+
embeddings: [0.00641461368650198, -0.0016253676731139421, -0.05126338079571724, 0.053438711911439896]
262243
refresh: true
263244

264245
- do:

0 commit comments

Comments
 (0)