Skip to content

Commit 3888e29

Browse files
authored
Merge branch 'main' into jackson221
2 parents 372680e + 4f63e10 commit 3888e29

File tree

23 files changed

+1446
-167
lines changed

23 files changed

+1446
-167
lines changed

docs/changelog/142181.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
area: Inference
2+
issues: []
3+
pr: 142181
4+
summary: "[Inference API] Do not write \"task\" field in Jina embedding request if\
5+
\ unsupported"
6+
type: bug

docs/changelog/142238.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
area: Inference
2+
issues: []
3+
pr: 142238
4+
summary: "[Inference API] Fix `ChunkingSettings` field missing from `ModelConfigurations` equals method"
5+
type: bug

modules/data-streams/src/main/java/org/elasticsearch/datastreams/action/TransportGetDataStreamsAction.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,15 @@ private static void collectIndexSettingsValues(
422422
) {
423423
for (Index index : backingIndices) {
424424
IndexMetadata indexMetadata = metadata.index(index);
425+
if (indexMetadata == null) {
426+
// This should never happen that the index metadata is null,
427+
// but protect against it defensively to prevent an NPE below regardless
428+
String message = "backing index [" + index.getName() + "] has null metadata in data stream [" + dataStream.getName() + "]";
429+
LOGGER.warn(message);
430+
assert false : message;
431+
backingIndicesSettingsValues.put(index, new IndexProperties(true, null, ManagedBy.UNMANAGED, null));
432+
continue;
433+
}
425434
Boolean preferIlm = PREFER_ILM_SETTING.get(indexMetadata.getSettings());
426435
assert preferIlm != null : "must use the default prefer ilm setting value, if nothing else";
427436
ManagedBy managedBy;

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/extras/MatchOnlyTextFieldMapper.java

Lines changed: 218 additions & 84 deletions
Large diffs are not rendered by default.

modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/extras/MatchOnlyTextFieldMapperTests.java

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.elasticsearch.index.IndexSettings;
3232
import org.elasticsearch.index.IndexVersions;
3333
import org.elasticsearch.index.mapper.DocumentMapper;
34+
import org.elasticsearch.index.mapper.FieldMapper;
3435
import org.elasticsearch.index.mapper.FieldStorageVerifier;
3536
import org.elasticsearch.index.mapper.KeywordFieldMapper;
3637
import org.elasticsearch.index.mapper.LuceneDocument;
@@ -109,6 +110,9 @@ protected void registerParameters(ParameterChecker checker) throws IOException {
109110
b -> { b.field("meta", Collections.singletonMap("format", "mysql.access")); },
110111
m -> assertEquals(Collections.singletonMap("format", "mysql.access"), m.fieldType().meta())
111112
);
113+
if (FieldMapper.DocValuesParameter.EXTENDED_DOC_VALUES_PARAMS_FF.isEnabled()) {
114+
checker.registerConflictCheck("doc_values", b -> b.field("doc_values", true));
115+
}
112116
}
113117

114118
@Override
@@ -686,4 +690,52 @@ protected List<SortShortcutSupport> getSortShortcutSupport() {
686690
protected boolean supportsDocValuesSkippers() {
687691
return false;
688692
}
693+
694+
public void testDocValuesDisabledByDefault() throws IOException {
695+
MapperService mapperService = createMapperService(fieldMapping(b -> b.field("type", "match_only_text")));
696+
MappedFieldType fieldType = mapperService.fieldType("field");
697+
assertFalse("doc_values should be disabled by default", fieldType.hasDocValues());
698+
}
699+
700+
public void testDocValuesEnabled() throws IOException {
701+
assumeTrue(
702+
"match_only_text field doc_values feature must be enabled",
703+
FieldMapper.DocValuesParameter.EXTENDED_DOC_VALUES_PARAMS_FF.isEnabled()
704+
);
705+
MapperService mapperService = createMapperService(fieldMapping(b -> b.field("type", "match_only_text").field("doc_values", true)));
706+
MappedFieldType fieldType = mapperService.fieldType("field");
707+
assertTrue("doc_values should be enabled", fieldType.hasDocValues());
708+
}
709+
710+
public void testDocValuesExplicitlyDisabled() throws IOException {
711+
assumeTrue(
712+
"match_only_text field doc_values feature must be enabled",
713+
FieldMapper.DocValuesParameter.EXTENDED_DOC_VALUES_PARAMS_FF.isEnabled()
714+
);
715+
MapperService mapperService = createMapperService(fieldMapping(b -> b.field("type", "match_only_text").field("doc_values", false)));
716+
MappedFieldType fieldType = mapperService.fieldType("field");
717+
assertFalse("doc_values should be disabled", fieldType.hasDocValues());
718+
}
719+
720+
public void testPhraseQueryWithDocValuesEnabled() throws IOException {
721+
assumeTrue(
722+
"match_only_text field doc_values feature must be enabled",
723+
FieldMapper.DocValuesParameter.EXTENDED_DOC_VALUES_PARAMS_FF.isEnabled()
724+
);
725+
MapperService mapperService = createMapperService(fieldMapping(b -> b.field("type", "match_only_text").field("doc_values", true)));
726+
727+
try (Directory directory = newDirectory()) {
728+
RandomIndexWriter iw = new RandomIndexWriter(random(), directory);
729+
LuceneDocument doc = mapperService.documentMapper().parse(source(b -> b.field("field", "the quick brown fox"))).rootDoc();
730+
iw.addDocument(doc);
731+
iw.close();
732+
try (DirectoryReader reader = DirectoryReader.open(directory)) {
733+
SearchExecutionContext context = createSearchExecutionContext(mapperService, newSearcher(reader));
734+
MatchPhraseQueryBuilder queryBuilder = new MatchPhraseQueryBuilder("field", "brown fox");
735+
TopDocs docs = context.searcher().search(queryBuilder.toQuery(context), 1);
736+
assertThat(docs.totalHits.value(), equalTo(1L));
737+
assertThat(docs.totalHits.relation(), equalTo(TotalHits.Relation.EQUAL_TO));
738+
}
739+
}
740+
}
689741
}

modules/mapper-extras/src/test/java/org/elasticsearch/index/mapper/extras/MatchOnlyTextFieldTypeTests.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ public void testBlockLoaderUsesStoredFieldsForLoadingWhenSyntheticSourceDelegate
242242
false,
243243
false,
244244
null,
245+
false,
246+
false,
245247
false
246248
);
247249

@@ -263,7 +265,9 @@ public void testBlockLoaderUsesBinaryDocValuesForLoadingWhenSyntheticSourceDeleg
263265
false,
264266
false,
265267
null,
266-
true
268+
true,
269+
false,
270+
false
267271
);
268272

269273
// when
@@ -291,7 +295,9 @@ public void testBlockLoaderUsesSyntheticSourceDelegateWhenIgnoreAboveIsNotSet()
291295
false,
292296
false,
293297
syntheticSourceDelegate,
294-
true
298+
true,
299+
false,
300+
false
295301
);
296302

297303
// when
@@ -337,6 +343,8 @@ public void testBlockLoaderDoesNotUseSyntheticSourceDelegateWhenIgnoreAboveIsSet
337343
false,
338344
false,
339345
syntheticSourceDelegate,
346+
false,
347+
false,
340348
false
341349
);
342350

@@ -386,6 +394,8 @@ public void testBlockLoaderDoesNotUseSyntheticSourceDelegateWhenIgnoreAboveIsSet
386394
false,
387395
false,
388396
syntheticSourceDelegate,
397+
false,
398+
false,
389399
false
390400
);
391401

@@ -420,6 +430,8 @@ public void testBlockLoaderDelegateToKeywordFieldWhenSyntheticSourceIsDisabled()
420430
true,
421431
false,
422432
keywordFieldType,
433+
false,
434+
false,
423435
false
424436
);
425437

@@ -467,6 +479,8 @@ public void testBlockLoaderLoadsFromFallbackStoredFieldWhenSyntheticSourceIsEnab
467479
false,
468480
false,
469481
null,
482+
false,
483+
false,
470484
false
471485
);
472486

@@ -489,7 +503,9 @@ public void testBlockLoaderLoadsFromFallbackBinaryDocValuesWhenSyntheticSourceIs
489503
false,
490504
false,
491505
null,
492-
true
506+
true,
507+
false,
508+
false
493509
);
494510

495511
// when

0 commit comments

Comments
 (0)