quickwit-oss/quickwit · error · anyhow::Error

timestamp field `{timestamp_field_path}` should be single-va

Error message

timestamp field `{timestamp_field_path}` should be single-valued

What it means

The timestamp field drives time-based pruning and retention, so Quickwit requires it to hold exactly one value per document. If the mapped field's `Cardinality` is not `SingleValued` (e.g. an array field), `validate_timestamp_field` bails during DocMapper construction.

Source

Thrown at quickwit/quickwit-doc-mapper/src/doc_mapper/doc_mapper_impl.rs:118

fn validate_timestamp_field(
    timestamp_field_path: &str,
    mapping_root_node: &MappingNode,
) -> anyhow::Result<()> {
    if timestamp_field_path.starts_with('.') || timestamp_field_path.starts_with("\\.") {
        bail!("timestamp field `{timestamp_field_path}` should not start with a `.`");
    }
    if timestamp_field_path.ends_with('.') {
        bail!("timestamp field `{timestamp_field_path}` should not end with a `.`");
    }
    let Some(timestamp_field_type) =
        mapping_root_node.find_field_mapping_type(timestamp_field_path)
    else {
        bail!("could not find timestamp field `{timestamp_field_path}` in field mappings");
    };
    if let FieldMappingType::DateTime(date_time_option, cardinality) = &timestamp_field_type {
        if cardinality != &Cardinality::SingleValued {
            bail!("timestamp field `{timestamp_field_path}` should be single-valued");
        }
        if !date_time_option.fast {
            bail!("timestamp field `{timestamp_field_path}` should be a fast field");
        }
    } else {
        bail!("timestamp field `{timestamp_field_path}` should be a datetime field");
    }
    Ok(())
}

impl From<DocMapper> for DocMapperBuilder {
    fn from(default_doc_mapper: DocMapper) -> Self {
        let partition_key_str = default_doc_mapper.partition_key.to_string();
        let partition_key_opt: Option<String> = if !partition_key_str.is_empty() {
            Some(partition_key_str)
        } else {
            None
        };

View on GitHub (pinned to a39730c5cd)

Solutions

  1. Change the field type in the doc mapping from `array<datetime>` to `datetime` (single-valued).
  2. Choose a different, single-valued datetime field as `timestamp_field`.
  3. If multiple timestamps must be kept, index the extra ones as separate non-timestamp fields.

Example fix

// before
doc_mapping:
  field_mappings:
    - name: ts
      type: array<datetime>
  timestamp_field: "ts"
// after
doc_mapping:
  field_mappings:
    - name: ts
      type: datetime
  timestamp_field: "ts"
Defensive patterns

Strategy: validation

Validate before calling

const f = findField(cfg.doc_mapping.field_mappings, cfg.doc_mapping.timestamp_field);
if (f && /^array</.test(f.type)) throw new Error(`timestamp_field "${f.name}" must be single-valued, not ${f.type}`);

Try / catch

match DocMapperBuilder::try_from(config) {
    Ok(dm) => Ok(dm),
    Err(e) if e.to_string().contains("should be single-valued") => Err(ConfigError::InvalidTimestampField(e.to_string())),
    Err(e) => Err(e.into()),
}

Prevention

When it happens

Trigger: Calling `DocMapperBuilder::try_from` with a `timestamp_field` that resolves to a field declared as an array/multi-valued datetime, e.g. `type: "array<datetime>"`.

Common situations: Users mapping log events that may contain several timestamps and declaring the field as an array, then referencing it as the index timestamp field; generic config generators defaulting to array types.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of quickwit-oss/quickwit@a39730c5cd (2026-09-08). Data as JSON: /api/errors/5420f5ba11b2d068. Report an issue: GitHub.