Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/121720.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 121720
summary: Skip fetching _inference_fields field in legacy semantic_text format
area: Search
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,8 @@ public static boolean isMetadataFieldStatic(String fieldName) {
* this method considers all mapper plugins
*/
public boolean isMetadataField(String field) {
return mapperRegistry.getMetadataMapperParsers(indexVersionCreated).containsKey(field);
var mapper = mappingLookup().getMapper(field);
return mapper instanceof MetadataFieldMapper;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public Set<NodeFeature> getTestFeatures() {
SemanticTextFieldMapper.SEMANTIC_TEXT_DELETE_FIX,
SemanticTextFieldMapper.SEMANTIC_TEXT_ZERO_SIZE_FIX,
SemanticTextFieldMapper.SEMANTIC_TEXT_ALWAYS_EMIT_INFERENCE_ID_FIX,
SemanticTextFieldMapper.SEMANTIC_TEXT_SKIP_INFERENCE_FIELDS,
SEMANTIC_TEXT_HIGHLIGHTER,
SEMANTIC_MATCH_QUERY_REWRITE_INTERCEPTION_SUPPORTED,
SEMANTIC_SPARSE_VECTOR_QUERY_REWRITE_INTERCEPTION_SUPPORTED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public class SemanticTextFieldMapper extends FieldMapper implements InferenceFie
public static final NodeFeature SEMANTIC_TEXT_ALWAYS_EMIT_INFERENCE_ID_FIX = new NodeFeature(
"semantic_text.always_emit_inference_id_fix"
);
public static final NodeFeature SEMANTIC_TEXT_SKIP_INFERENCE_FIELDS = new NodeFeature("semantic_text.skip_inference_fields");

public static final String CONTENT_TYPE = "semantic_text";
public static final String DEFAULT_ELSER_2_INFERENCE_ID = DEFAULT_ELSER_ID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,3 +650,27 @@ setup:
- match: { hits.total.value: 1 }
- match: { hits.total.relation: eq }
- match: { hits.hits.0._source.dense_field.text: "updated text" }

---
"Skip fetching _inference_fields":
- requires:
cluster_features: semantic_text.skip_inference_fields
reason: Skip _inference_fields when search is performed on legacy semantic_text format.

- do:
index:
index: test-index
id: doc_1
body:
sparse_field: "test value"
refresh: true

- do:
search:
index: test-index
body:
fields: [ _inference_fields ]
query:
match_all: { }

- not_exists: hits.hits.0._source._inference_fields