Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to skip using _ignored_source field for synthetic source #112963

Merged
merged 8 commits into from
Sep 17, 2024

Conversation

lkts
Copy link
Contributor

@lkts lkts commented Sep 16, 2024

Closes #112940.

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@lkts
Copy link
Contributor Author

lkts commented Sep 17, 2024

Diff is mostly tests.


String syntheticSource = syntheticSource(mapperService, inputDocument);
// Values are not loaded.
assertEquals("{}", syntheticSource);
Copy link
Contributor

@kkrik-es kkrik-es Sep 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flip to false, verify that the field gets read.


String syntheticSource = syntheticSource(mapperService, inputDocument);
// Values are not loaded.
assertEquals("{}", syntheticSource);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

assertThat(roundTripSyntheticSource, equalTo(syntheticSource));
validateRoundTripReader(syntheticSource, reader, roundTripReader);
}
}
}

protected static String syntheticSource(DocumentMapper mapper, IndexReader reader, int docId) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep this flavor and pass empty indexSettings for the cases we don't care. That should reduce the churn for testing files..


static final NodeFeature TRACK_IGNORED_SOURCE = new NodeFeature("mapper.track_ignored_source");

public static final Setting<Boolean> SKIP_IGNORED_SOURCE_WRITE_SETTING = Setting.boolSetting(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add java doc on top of these public settings to explain what they do exactly?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the java doc is now empty

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fixed.

this.syntheticFieldLoaderLeafSupplier = fieldLoaderSupplier;
this.requiredStoredFields = syntheticFieldLoaderLeafSupplier.get()
.storedFieldLoaders()
.map(Map.Entry::getKey)
.collect(Collectors.toSet());
this.requiredStoredFields.add(IgnoredSourceFieldMapper.NAME);
if (indexSettings.getSkipIgnoredSourceRead() == false) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding was that we only need to ignore _ignore_source at read time, like is done here. This to avoid the potential errors when synthesizing the source. An escape hatch. Do we need ignore _ignore_source at write time?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to add both, in case we have a bug at some point (...) with indexing. These settings won't be advertised, but we can give them to support in case we have a really urgent SDH (ingestion blocked etc).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I see. An another escape hatch if for some reason we have a bug at index time.

@lkts
Copy link
Contributor Author

lkts commented Sep 17, 2024

@elasticmachine update branch

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - this approach is cleaner


static final NodeFeature TRACK_IGNORED_SOURCE = new NodeFeature("mapper.track_ignored_source");

public static final Setting<Boolean> SKIP_IGNORED_SOURCE_WRITE_SETTING = Setting.boolSetting(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the java doc is now empty

@lkts lkts merged commit 36b3549 into elastic:main Sep 17, 2024
14 checks passed
@lkts lkts deleted the skip_ignore_source_setting branch September 17, 2024 20:47
lkts added a commit to lkts/elasticsearch that referenced this pull request Sep 17, 2024
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.x
8.15 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 112963

@lkts
Copy link
Contributor Author

lkts commented Sep 17, 2024

💚 All backports created successfully

Status Branch Result
8.15

Questions ?

Please refer to the Backport tool documentation

lkts added a commit to lkts/elasticsearch that referenced this pull request Sep 17, 2024
…lastic#112963)

(cherry picked from commit 36b3549)

# Conflicts:
#	server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java
#	server/src/main/java/org/elasticsearch/index/IndexSettings.java
#	server/src/main/java/org/elasticsearch/index/mapper/DocumentParserContext.java
#	server/src/main/java/org/elasticsearch/index/mapper/NestedObjectMapper.java
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapper.java
lkts added a commit that referenced this pull request Sep 17, 2024
…112963) (#113065)

(cherry picked from commit 36b3549)

# Conflicts:
#	server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java
#	server/src/main/java/org/elasticsearch/index/IndexSettings.java
#	server/src/main/java/org/elasticsearch/index/mapper/DocumentParserContext.java
#	server/src/main/java/org/elasticsearch/index/mapper/NestedObjectMapper.java
#	x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapper.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce a setting to skip using ignoredSource
5 participants