Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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/135039.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 135039
summary: Use optimized field visitor for ignored source queries
area: Mapping
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,12 @@ private static Version parseUnchecked(String version) {
public static final IndexVersion SPARSE_VECTOR_PRUNING_INDEX_OPTIONS_SUPPORT = def(9_031_0_00, Version.LUCENE_10_2_2);
public static final IndexVersion DEFAULT_DENSE_VECTOR_TO_BBQ_HNSW = def(9_032_0_00, Version.LUCENE_10_2_2);
public static final IndexVersion MATCH_ONLY_TEXT_STORED_AS_BYTES = def(9_033_0_00, Version.LUCENE_10_2_2);
public static final IndexVersion IGNORED_SOURCE_FIELDS_PER_ENTRY_WITH_FF = def(9_034_0_00, Version.LUCENE_10_2_2);
public static final IndexVersion IGNORED_SOURCE_COALESCED_ENTRIES_WITH_FF = def(9_034_0_00, Version.LUCENE_10_2_2);
public static final IndexVersion EXCLUDE_SOURCE_VECTORS_DEFAULT = def(9_035_0_00, Version.LUCENE_10_2_2);
public static final IndexVersion DISABLE_NORMS_BY_DEFAULT_FOR_LOGSDB_AND_TSDB = def(9_036_0_00, Version.LUCENE_10_2_2);
public static final IndexVersion TSID_CREATED_DURING_ROUTING = def(9_037_0_00, Version.LUCENE_10_2_2);
public static final IndexVersion UPGRADE_TO_LUCENE_10_3_0 = def(9_038_0_00, Version.LUCENE_10_3_0);
public static final IndexVersion IGNORED_SOURCE_COALESCED_ENTRIES = def(9_039_0_00, Version.LUCENE_10_3_0);

/*
* STOP! READ THIS FIRST! No, really,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,13 @@ public IgnoredSourceFormat ignoredSourceFormat() {
}

public static IgnoredSourceFormat ignoredSourceFormat(IndexVersion indexCreatedVersion) {
return indexCreatedVersion.onOrAfter(IndexVersions.IGNORED_SOURCE_FIELDS_PER_ENTRY_WITH_FF)
&& COALESCE_IGNORED_SOURCE_ENTRIES.isEnabled()
? IgnoredSourceFormat.COALESCED_SINGLE_IGNORED_SOURCE
: IgnoredSourceFormat.LEGACY_SINGLE_IGNORED_SOURCE;
IndexVersion switchToNewFormatVersion = COALESCE_IGNORED_SOURCE_ENTRIES.isEnabled()
? IndexVersions.IGNORED_SOURCE_COALESCED_ENTRIES_WITH_FF
: IndexVersions.IGNORED_SOURCE_COALESCED_ENTRIES;

return indexCreatedVersion.onOrAfter(switchToNewFormatVersion)
? IgnoredSourceFormat.COALESCED_SINGLE_IGNORED_SOURCE
: IgnoredSourceFormat.LEGACY_SINGLE_IGNORED_SOURCE;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,7 @@ public void testEncodeFieldToMap() throws IOException {
ParsedDocument parsedDocument = getParsedDocumentWithFieldLimit(b -> b.field("my_value", value));
IgnoredSourceFieldMapper.MappedNameValue mappedNameValue;
var bytes = parsedDocument.rootDoc().getField(IgnoredSourceFieldMapper.NAME).binaryValue();
if (IgnoredSourceFieldMapper.COALESCE_IGNORED_SOURCE_ENTRIES.isEnabled()) {
mappedNameValue = IgnoredSourceFieldMapper.CoalescedIgnoredSourceEncoding.decodeAsMap(bytes).getFirst();
} else {
mappedNameValue = IgnoredSourceFieldMapper.LegacyIgnoredSourceEncoding.decodeAsMap(bytes);
}
mappedNameValue = IgnoredSourceFieldMapper.CoalescedIgnoredSourceEncoding.decodeAsMap(bytes).getFirst();
assertEquals("my_value", mappedNameValue.nameValue().name());
assertEquals(value, mappedNameValue.map().get("my_value"));
}
Expand All @@ -360,18 +356,10 @@ public void testEncodeObjectToMapAndDecode() throws IOException {
);
var bytes = parsedDocument.rootDoc().getField(IgnoredSourceFieldMapper.NAME).binaryValue();
IgnoredSourceFieldMapper.MappedNameValue mappedNameValue;
if (IgnoredSourceFieldMapper.COALESCE_IGNORED_SOURCE_ENTRIES.isEnabled()) {
mappedNameValue = IgnoredSourceFieldMapper.CoalescedIgnoredSourceEncoding.decodeAsMap(bytes).getFirst();
} else {
mappedNameValue = IgnoredSourceFieldMapper.LegacyIgnoredSourceEncoding.decodeAsMap(bytes);
}
mappedNameValue = IgnoredSourceFieldMapper.CoalescedIgnoredSourceEncoding.decodeAsMap(bytes).getFirst();
assertEquals("my_object", mappedNameValue.nameValue().name());
assertEquals(value, ((Map<String, ?>) mappedNameValue.map().get("my_object")).get("my_value"));
if (IgnoredSourceFieldMapper.COALESCE_IGNORED_SOURCE_ENTRIES.isEnabled()) {
assertEquals(bytes, IgnoredSourceFieldMapper.CoalescedIgnoredSourceEncoding.encodeFromMap(List.of(mappedNameValue)));
} else {
assertEquals(bytes, IgnoredSourceFieldMapper.LegacyIgnoredSourceEncoding.encodeFromMap(mappedNameValue));
}
assertEquals(bytes, IgnoredSourceFieldMapper.CoalescedIgnoredSourceEncoding.encodeFromMap(List.of(mappedNameValue)));
}

public void testEncodeArrayToMapAndDecode() throws IOException {
Expand All @@ -383,18 +371,10 @@ public void testEncodeArrayToMapAndDecode() throws IOException {
});
var bytes = parsedDocument.rootDoc().getField(IgnoredSourceFieldMapper.NAME).binaryValue();
IgnoredSourceFieldMapper.MappedNameValue mappedNameValue;
if (IgnoredSourceFieldMapper.COALESCE_IGNORED_SOURCE_ENTRIES.isEnabled()) {
mappedNameValue = IgnoredSourceFieldMapper.CoalescedIgnoredSourceEncoding.decodeAsMap(bytes).getFirst();
} else {
mappedNameValue = IgnoredSourceFieldMapper.LegacyIgnoredSourceEncoding.decodeAsMap(bytes);
}
mappedNameValue = IgnoredSourceFieldMapper.CoalescedIgnoredSourceEncoding.decodeAsMap(bytes).getFirst();
assertEquals("my_array", mappedNameValue.nameValue().name());
assertThat((List<?>) mappedNameValue.map().get("my_array"), Matchers.contains(Map.of("int_value", 10), Map.of("int_value", 20)));
if (IgnoredSourceFieldMapper.COALESCE_IGNORED_SOURCE_ENTRIES.isEnabled()) {
assertEquals(bytes, IgnoredSourceFieldMapper.CoalescedIgnoredSourceEncoding.encodeFromMap(List.of(mappedNameValue)));
} else {
assertEquals(bytes, IgnoredSourceFieldMapper.LegacyIgnoredSourceEncoding.encodeFromMap(mappedNameValue));
}
assertEquals(bytes, IgnoredSourceFieldMapper.CoalescedIgnoredSourceEncoding.encodeFromMap(List.of(mappedNameValue)));
}

public void testMultipleIgnoredFieldsRootObject() throws IOException {
Expand Down
6 changes: 0 additions & 6 deletions x-pack/plugin/logsdb/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,4 @@ tasks.named("javaRestTest").configure {

tasks.named('yamlRestTest') {
usesDefaultDistribution("Requires a bunch of xpack plugins")

if (buildParams.snapshotBuild == false) {
systemProperty 'tests.rest.blacklist', [
'20_ignored_source/*'
].join(',')
}
}