Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 6 additions & 0 deletions docs/changelog/121720.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 121720
summary: Fix - Requesting `_inference_fields` when using legacy format causes shard
failure
area: Relevance
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public FetchSubPhaseProcessor getProcessor(FetchContext fetchContext) {
.stream()
.filter(
fieldAndFormat -> (searchExecutionContext.isMetadataField(fieldAndFormat.field) == false
|| searchExecutionContext.fieldExistsInIndex(fieldAndFormat.field) == false
|| searchExecutionContext.getFieldType(fieldAndFormat.field).isStored() == false
|| IdFieldMapper.NAME.equals(fieldAndFormat.field)
|| SourceFieldMapper.NAME.equals(fieldAndFormat.field))
Expand All @@ -87,6 +88,7 @@ public FetchSubPhaseProcessor getProcessor(FetchContext fetchContext) {
continue;
}
if (searchExecutionContext.isMetadataField(fieldAndFormat.field)
&& searchExecutionContext.fieldExistsInIndex(fieldAndFormat.field)
&& searchExecutionContext.getFieldType(fieldAndFormat.field).isStored()) {
fetchContextMetadataFields.add(fieldAndFormat);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1003,3 +1003,60 @@ setup:
- length: { aggregations.agg_ids.buckets: 1 }
- match: { aggregations.agg_ids.buckets.0.key: "doc_1" }
- match: { aggregations.agg_ids.buckets.0.doc_count: 1 }

---
"Querying_inference_fields with semantic_text legacy format":
- do:
inference.put:
task_type: sparse_embedding
inference_id: sparse-inference-id
body: >
{
"service": "test_service",
"service_settings": {
"model": "my_model",
"api_key": "abc64"
},
"task_settings": {
}
}

- do:
indices.create:
index: test-index
body:
settings:
index:
mapping:
semantic_text:
use_legacy_format: true
mappings:
properties:
inference_field:
type: semantic_text
inference_id: sparse-inference-id
source_field:
type: text
copy_to: inference_field

- do:
index:
index: test-index
id: doc_1
body:
inference_field: "test value"
source_field: "source value"
refresh: true

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

- match: { hits.total.value: 1 }
- match: { hits.total.relation: eq }
- match: { hits.hits.0._source.source_field: "source value" }
- match: { hits.hits.0._source.inference_field.text: "test value" }