feat(elasticsearch_api): pushdown start/end timestamp on _mapping endpoint#6355
Open
congx4 wants to merge 1 commit intoquickwit-oss:mainfrom
Open
feat(elasticsearch_api): pushdown start/end timestamp on _mapping endpoint#6355congx4 wants to merge 1 commit intoquickwit-oss:mainfrom
congx4 wants to merge 1 commit intoquickwit-oss:mainfrom
Conversation
…point
Today, GET /_elastic/{index}/_mapping always builds a ListFieldsRequest
with start_timestamp = end_timestamp = None, scanning every published
split to compute the response. On large clusters with many dynamic fields
this can produce multi-second latencies and tens of megabytes of payload
before any HTTP gateway timeout fires.
ListFieldsRequest already supports time-based split pruning via
optional int64 start_timestamp / end_timestamp (epoch seconds, half-open
interval) — that infrastructure has just never been exposed at the
ES-compat HTTP surface. This change adds two optional URL query params
with the same names and unit, deserializes them via warp::query(), and
forwards them into ListFieldsRequest verbatim. Behaviour with no query
string is identical to today (both fields stay None).
Files changed:
- New IndexMappingQueryParams model with serde derives + 5 unit tests
covering parser defaults, both-present, partial, and the
deny_unknown_fields rejection path.
- elastic_index_mapping_filter now extracts (String, IndexMappingQueryParams)
via .and(warp::query()).
- es_compat_index_mapping takes the params struct as its second arg and
threads start_timestamp / end_timestamp into ListFieldsRequest.
- serde_urlencoded added as a dev-dependency for parser-level tests
(already a transitive dep via warp).
Backward-compatible: any client sending no query string keeps today's
exact behaviour.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds two optional URL query parameters to the ES-compatibility
_mappingendpoint (GET /_elastic/{index}/_mappingand/_mappings):start_timestamp(epoch seconds)end_timestamp(epoch seconds)When present, they are forwarded into
quickwit_proto::search::ListFieldsRequest.start_timestamp/end_timestampverbatim, enabling timestamp-based split pruning during field discovery. When absent, behaviour is identical to today (both proto fields stayNone).The proto already documents these fields:
The infrastructure (
list_relevant_splitshonouring the window) has long been wired throughListFieldsRequest; this change just exposes the existing knob at the HTTP surface.Why
Today
es_compat_index_mappinghardcodesstart_timestamp: None, end_timestamp: None, so every call scans every published split for every dynamic field. On large clusters with manycustom.*/tag.*fields and months of data, the response can balloon to tens of megabytes and 30+ seconds — long enough to time out behind any modestly aggressive HTTP gateway. With the time window pushed down, mapping responses shrink dramatically.Changes
quickwit-serve/src/elasticsearch_api/model/index_mapping_query_params.rs—IndexMappingQueryParamsstruct withOption<i64>fields,serde::Deserialize,#[serde(deny_unknown_fields)](matchingSearchQueryParams/CatIndexQueryParamsconvention), plus 5 parser-level unit tests.model/mod.rs— module declaration +pub usere-export.elasticsearch_api/filter.rs::elastic_index_mapping_filter— now extracts(String, IndexMappingQueryParams)via.and(warp::query()), mirroring the pattern inelasticsearch_filterandelastic_index_count_filter.elasticsearch_api/rest_handler.rs::es_compat_index_mapping— acceptsparams: IndexMappingQueryParamsas its second argument and readsparams.start_timestamp/params.end_timestampintoListFieldsRequest. The factoryes_compat_index_mapping_handlerneeds no edits — warp threads the new tuple element through positionally.Cargo.toml(workspace) andquickwit-serve/Cargo.toml—serde_urlencodedadded as a dev-dependency for the parser-level tests (already a transitive dep via warp).Backward compatibility
Fully backward-compatible. Clients that omit the query parameters get exactly today's behaviour. The
deny_unknown_fieldssetting matches the existing convention on neighbouring endpoints (SearchQueryParams,CatIndexQueryParams); this means a stray?pretty=truewould now return 400 — but this matches_search's existing behaviour, so the surface is consistent across endpoints.Test plan
cargo test -p quickwit-serve— 154 tests passed, 0 failed (5 new tests included).cargo build -p quickwit-serve— builds clean.cargo clippy -p quickwit-serve --all-features --tests— clean.None/None), both params present, only one present, unknown field rejected.Notes
CHANGELOG.mdbecause the[Unreleased]section is HTML-commented out in the file, suggesting maintainers update it during release. Happy to add an entry if preferred.ListFieldsRequestfields already exist.🤖 Generated with Claude Code