-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Fix PerFieldFormatSupplier mistake #134008
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
Merged
dnhatn
merged 10 commits into
elastic:main
from
martijnvg:fix_seqno_field_use_tsdb_doc_values_format_ff
Sep 3, 2025
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
499bef6
Fix PerFieldFormatSupplier bug
martijnvg feab7d0
Include #134006
dnhatn e78685b
Add comment
dnhatn abfab67
adjust test
martijnvg 844fe3b
Merge remote-tracking branch 'es/main' into fix_seqno_field_use_tsdb_…
martijnvg 9773326
iter
martijnvg c5b61da
Merge remote-tracking branch 'es/main' into fix_seqno_field_use_tsdb_…
martijnvg c915fb8
Merge remote-tracking branch 'es/main' into fix_seqno_field_use_tsdb_…
martijnvg 544288a
Merge remote-tracking branch 'es/main' into fix_seqno_field_use_tsdb_…
martijnvg a5dd636
Merge remote-tracking branch 'es/main' into fix_seqno_field_use_tsdb_…
martijnvg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,15 +27,37 @@ | |
import org.elasticsearch.index.mapper.Mapper; | ||
import org.elasticsearch.index.mapper.MapperService; | ||
import org.elasticsearch.index.mapper.SeqNoFieldMapper; | ||
import org.elasticsearch.index.mapper.TimeSeriesIdFieldMapper; | ||
import org.elasticsearch.index.mapper.TimeSeriesRoutingHashFieldMapper; | ||
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper; | ||
|
||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
/** | ||
* Class that encapsulates the logic of figuring out the most appropriate file format for a given field, across postings, doc values and | ||
* vectors. | ||
*/ | ||
public class PerFieldFormatSupplier { | ||
|
||
private static final FeatureFlag SEQNO_FIELD_USE_TSDB_DOC_VALUES_FORMAT = new FeatureFlag("seqno_field_use_tsdb_doc_values_format"); | ||
static final FeatureFlag SEQNO_FIELD_USE_TSDB_DOC_VALUES_FORMAT = new FeatureFlag("seqno_field_use_tsdb_doc_values_format"); | ||
private static final Set<String> INCLUDE_META_FIELDS; | ||
|
||
static { | ||
// TODO: should we just allow all fields to use tsdb doc values codec? | ||
// Avoid using tsdb codec for fields like _seq_no, _primary_term. | ||
// But _tsid and _ts_routing_hash should always use the tsdb codec. | ||
Set<String> includeMetaField = new HashSet<>(3); | ||
includeMetaField.add(TimeSeriesIdFieldMapper.NAME); | ||
includeMetaField.add(TimeSeriesRoutingHashFieldMapper.NAME); | ||
if (SEQNO_FIELD_USE_TSDB_DOC_VALUES_FORMAT.isEnabled()) { | ||
includeMetaField.add(SeqNoFieldMapper.NAME); | ||
} | ||
// Don't include _recovery_source_size and _recovery_source since their values can be filtered out in | ||
// RecoverySourcePruneMergePolicy which leads to inconsistencies between merge stats and actual values. | ||
INCLUDE_META_FIELDS = Collections.unmodifiableSet(includeMetaField); | ||
} | ||
|
||
private static final DocValuesFormat docValuesFormat = new Lucene90DocValuesFormat(); | ||
private static final KnnVectorsFormat knnVectorsFormat = new Lucene99HnswVectorsFormat(); | ||
|
@@ -126,13 +148,7 @@ boolean useTSDBDocValuesFormat(final String field) { | |
} | ||
|
||
private boolean excludeFields(String fieldName) { | ||
// TODO: should we just allow all fields to use tsdb doc values codec? | ||
// Avoid using tsdb codec for fields like _seq_no, _primary_term. | ||
// But _tsid and _ts_routing_hash should always use the tsdb codec. | ||
return fieldName.startsWith("_") | ||
&& fieldName.equals("_tsid") == false | ||
&& fieldName.equals("_ts_routing_hash") == false | ||
&& (SEQNO_FIELD_USE_TSDB_DOC_VALUES_FORMAT.isEnabled() && fieldName.equals(SeqNoFieldMapper.NAME) == false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Checking whether feature flag is enabled and whether seqno should not be excluded can't be expressed this way. Because if feature flag is disabled this then results in the field not being excluded. |
||
return fieldName.startsWith("_") && INCLUDE_META_FIELDS.contains(fieldName) == false; | ||
} | ||
|
||
private boolean isTimeSeriesModeIndex() { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is off?