Skip to content

Commit f837041

Browse files
committed
address review
1 parent 307983c commit f837041

2 files changed

Lines changed: 105 additions & 1 deletion

File tree

modules/reindex/src/main/java/org/elasticsearch/reindex/AbstractAsyncBulkByScrollAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static <Request extends AbstractBulkByScrollRequest<Request>> SearchRequest prep
214214
// always include vectors in the response unless explicitly set
215215
var fetchSource = sourceBuilder.fetchSource();
216216
if (fetchSource == null) {
217-
sourceBuilder.fetchSource(FetchSourceContext.of(true, false, new String[0], new String[0]));
217+
sourceBuilder.fetchSource(FetchSourceContext.FETCH_ALL_SOURCE_EXCLUDE_INFERENCE_FIELDS);
218218
} else if (fetchSource.excludeVectors() == null) {
219219
sourceBuilder.excludeVectors(false);
220220
}

x-pack/plugin/inference/src/yamlRestTest/resources/rest-api-spec/test/inference/30_semantic_text_inference.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,11 @@ setup:
348348
indices.create:
349349
index: destination-index
350350
body:
351+
settings:
352+
index:
353+
mapping:
354+
semantic_text:
355+
use_legacy_format: false
351356
mappings:
352357
properties:
353358
sparse_field:
@@ -370,6 +375,105 @@ setup:
370375
dest:
371376
index: destination-index
372377

378+
- match: { created: 1 }
379+
- match: { updated: 0 }
380+
- match: { version_conflicts: 0 }
381+
- match: { failures: [ ] }
382+
383+
- do:
384+
indices.refresh: { }
385+
386+
- do:
387+
get:
388+
index: destination-index
389+
id: doc_1
390+
391+
- match: { _source.sparse_field: "inference test" }
392+
- match: { _source.dense_field: "another inference test" }
393+
- match: { _source.non_inference_field: "non inference test" }
394+
395+
- do:
396+
search:
397+
index: destination-index
398+
body:
399+
_source:
400+
exclude_vectors: false
401+
query:
402+
match_all: {}
403+
404+
- match: { hits.total.value: 1 }
405+
- match: { hits.total.relation: eq }
406+
407+
- length: { hits.hits.0._source._inference_fields.sparse_field.inference.chunks: 1 }
408+
- length: { hits.hits.0._source._inference_fields.sparse_field.inference.chunks.sparse_field: 1 }
409+
- exists: hits.hits.0._source._inference_fields.sparse_field.inference.chunks.sparse_field.0.embeddings
410+
- match: { hits.hits.0._source._inference_fields.sparse_field.inference.chunks.sparse_field.0.start_offset: 0 }
411+
- match: { hits.hits.0._source._inference_fields.sparse_field.inference.chunks.sparse_field.0.end_offset: 14 }
412+
413+
- length: { hits.hits.0._source._inference_fields.dense_field.inference.chunks: 1 }
414+
- length: { hits.hits.0._source._inference_fields.dense_field.inference.chunks.dense_field: 1 }
415+
- exists: hits.hits.0._source._inference_fields.dense_field.inference.chunks.dense_field.0.embeddings
416+
- match: { hits.hits.0._source._inference_fields.dense_field.inference.chunks.dense_field.0.start_offset: 0 }
417+
- match: { hits.hits.0._source._inference_fields.dense_field.inference.chunks.dense_field.0.end_offset: 22 }
418+
419+
---
420+
"Reindex recomputes embeddings by default":
421+
- do:
422+
index:
423+
index: test-index
424+
id: doc_1
425+
body:
426+
sparse_field: "inference test"
427+
dense_field: "another inference test"
428+
non_inference_field: "non inference test"
429+
refresh: true
430+
431+
- do:
432+
indices.create:
433+
index: destination-index
434+
body:
435+
settings:
436+
index:
437+
mapping:
438+
semantic_text:
439+
use_legacy_format: false
440+
mappings:
441+
properties:
442+
sparse_field:
443+
type: semantic_text
444+
inference_id: dense-inference-id
445+
dense_field:
446+
type: semantic_text
447+
inference_id: sparse-inference-id
448+
non_inference_field:
449+
type: text
450+
451+
# reindex fails when preserving embeddings
452+
- do:
453+
catch: bad_request
454+
reindex:
455+
wait_for_completion: true
456+
body:
457+
source:
458+
index: test-index
459+
_source:
460+
exclude_vectors: false
461+
dest:
462+
index: destination-index
463+
464+
- length: { failures: 1 }
465+
466+
# reindex succeeds when embeddings are recomputed
467+
- do:
468+
reindex:
469+
wait_for_completion: true
470+
body:
471+
source:
472+
index: test-index
473+
dest:
474+
index: destination-index
475+
476+
- match: { created: 1 }
373477
- match: { updated: 0 }
374478
- match: { version_conflicts: 0 }
375479
- match: { failures: [ ] }

0 commit comments

Comments
 (0)