Skip to content

Commit ab83cf7

Browse files
committed
Added YAML test
1 parent 399faba commit ab83cf7

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ public Set<NodeFeature> getTestFeatures() {
4949
SemanticInferenceMetadataFieldsMapper.INFERENCE_METADATA_FIELDS_ENABLED_BY_DEFAULT,
5050
SEMANTIC_TEXT_HIGHLIGHTER_DEFAULT,
5151
SEMANTIC_KNN_FILTER_FIX,
52-
TEST_RERANKING_SERVICE_PARSE_TEXT_AS_SCORE
52+
TEST_RERANKING_SERVICE_PARSE_TEXT_AS_SCORE,
53+
SemanticTextFieldMapper.SEMANTIC_TEXT_BIT_VECTOR_SUPPORT
5354
);
5455
}
5556
}

x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ public class SemanticTextFieldMapper extends FieldMapper implements InferenceFie
118118
"semantic_text.always_emit_inference_id_fix"
119119
);
120120
public static final NodeFeature SEMANTIC_TEXT_SKIP_INFERENCE_FIELDS = new NodeFeature("semantic_text.skip_inference_fields");
121+
public static final NodeFeature SEMANTIC_TEXT_BIT_VECTOR_SUPPORT = new NodeFeature("semantic_text.bit_vector_support");
121122

122123
public static final String CONTENT_TYPE = "semantic_text";
123124
public static final String DEFAULT_ELSER_2_INFERENCE_ID = DEFAULT_ELSER_ID;

x-pack/plugin/inference/src/yamlRestTest/resources/rest-api-spec/test/inference/40_semantic_text_query.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,70 @@ setup:
351351
- match: { hits.hits.0._id: "doc_1" }
352352
- close_to: { hits.hits.0._score: { value: 1.0, error: 0.0001 } }
353353

354+
---
355+
"Query using a dense embedding model that uses bit embeddings":
356+
- requires:
357+
cluster_features: "semantic_text.bit_vector_support"
358+
reason: Bit vector support
359+
360+
- skip:
361+
features: [ "headers", "close_to" ]
362+
363+
- do:
364+
inference.put:
365+
task_type: text_embedding
366+
inference_id: dense-inference-bit-id
367+
body: >
368+
{
369+
"service": "text_embedding_test_service",
370+
"service_settings": {
371+
"model": "my_model",
372+
"dimensions": 16,
373+
"api_key": "abc64",
374+
"similarity": "L2_NORM",
375+
"element_type": "bit"
376+
},
377+
"task_settings": {
378+
}
379+
}
380+
381+
- do:
382+
indices.create:
383+
index: test-dense-bit-index
384+
body:
385+
mappings:
386+
properties:
387+
inference_field:
388+
type: semantic_text
389+
inference_id: dense-inference-bit-id
390+
non_inference_field:
391+
type: text
392+
393+
- do:
394+
index:
395+
index: test-dense-bit-index
396+
id: doc_1
397+
body:
398+
inference_field: [ "inference test", "another inference test" ]
399+
non_inference_field: "non inference test"
400+
refresh: true
401+
402+
- do:
403+
headers:
404+
# Force JSON content type so that we use a parser that interprets the floating-point score as a double
405+
Content-Type: application/json
406+
search:
407+
index: test-dense-bit-index
408+
body:
409+
query:
410+
semantic:
411+
field: "inference_field"
412+
query: "inference test"
413+
414+
- match: { hits.total.value: 1 }
415+
- match: { hits.hits.0._id: "doc_1" }
416+
- close_to: { hits.hits.0._score: { value: 1.0, error: 0.0001 } }
417+
354418
---
355419
"Query using a dense embedding model via a search inference ID":
356420
- skip:

0 commit comments

Comments
 (0)