Skip to content

Conversation

jordan-powers
Copy link
Contributor

@jordan-powers jordan-powers commented Sep 23, 2025

This patch moves the logic for figuring out index sorting defaults from IndexSortConfig into the IndexSettingProviders for logsdb and tsdb.

Fixes #129062

This is starting to be a big PR, but it's mostly just new tests. The change to the actual logic is fairly contained.

@jordan-powers jordan-powers changed the title Include default index sort Move logsdb index sorting d efaults to LogsdbindexModeSettingsProvider Sep 23, 2025
@jordan-powers jordan-powers self-assigned this Sep 23, 2025
@jordan-powers jordan-powers added WIP :StorageEngine/Mapping The storage related side of mappings labels Sep 23, 2025
@jordan-powers jordan-powers changed the title Move logsdb index sorting d efaults to LogsdbindexModeSettingsProvider Move index sorting defaults to IndexSettingProviders Sep 23, 2025
@jordan-powers jordan-powers force-pushed the include-default-index-sort branch from 36af3ad to d52e967 Compare September 25, 2025 03:41
@jordan-powers jordan-powers removed the WIP label Sep 30, 2025
@jordan-powers jordan-powers marked this pull request as ready for review October 1, 2025 03:42
@elasticsearchmachine
Copy link
Collaborator

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

builder.putList(IndexSortConfig.INDEX_SORT_FIELD_SETTING.getKey(), DataStreamTimestampFieldMapper.DEFAULT_PATH);
builder.putList(IndexSortConfig.INDEX_SORT_ORDER_SETTING.getKey(), "desc");
builder.putList(IndexSortConfig.INDEX_SORT_MODE_SETTING.getKey(), "min");
builder.putList(IndexSortConfig.INDEX_SORT_MISSING_SETTING.getKey(), "_last");
Copy link
Contributor

@parkertimmins parkertimmins Oct 1, 2025

Choose a reason for hiding this comment

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

I think mode should be max, since order is descending and this line computes the mode? https://github.com/elastic/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/index/IndexSortConfig.java#L279

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, you're right, looks like I misread the condition. It's difficult to test this since data streams reject documents with multi-valued timestamps.

DataStreamTimestampFieldMapper.DEFAULT_PATH
);
builder.putList(IndexSortConfig.INDEX_SORT_ORDER_SETTING.getKey(), "asc", "desc");
builder.putList(IndexSortConfig.INDEX_SORT_MODE_SETTING.getKey(), "min", "min");
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly to below, I think this should be min, max


- match: { error.type: "illegal_argument_exception" }
- match: { error.reason: "index.sort.fields:[] index.sort.order:[asc, asc], size mismatch" }
- match: { error.reason: "index.sort.field:[] index.sort.order:[asc, asc], size mismatch" }
Copy link
Member

Choose a reason for hiding this comment

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

Why is index.sort.fields renamed to index.sort.field in this error message?

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 the error message now originates from another place and index setting name is incorrect was incorrect.

"index": {
"routing_path": [ "hostname" ],
"mode": "time_series",
"sort.field": [],
Copy link
Member

Choose a reason for hiding this comment

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

Did an empty sort.field yield the default before? And no longer and therefor this needed to be updated?

additionalSettings.put(PatternTextFieldMapper.DISABLE_TEMPLATING_SETTING.getKey(), true);
}

if (isLogsDB && isTemplateValidation == false && IndexSortConfig.INDEX_SORT_FIELD_SETTING.exists(settings) == false) {
Copy link
Member

Choose a reason for hiding this comment

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

I forgot ,why didn't defining the defaults out via index sort settings in IndexSortConfig? (as setting default)
Additionally could this be done in IndexMode like is done for time series index mode?

@jordan-powers
Copy link
Contributor Author

Closed in favor of #135886

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.

Include index.sort.* index settings defaults for time_series and logsdb index modes.

4 participants