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

`record` and `tokenizer` parameters are allowed only if inde

Error message

`record` and `tokenizer` parameters are allowed only if indexed is true

What it means

Same rule as error 83 but for JSON-type field mappings: when indexed=false, a JSON field may not carry `record` or `tokenizer` options. The from_parts_json constructor treats their presence as contradictory and rejects the mapping.

Source

Thrown at quickwit/quickwit-doc-mapper/src/doc_mapper/field_mapping_entry.rs:353

            }
            Ok(None)
        }
    }

    fn from_parts_json(
        indexed: bool,
        tokenizer: Option<QuickwitTextTokenizer>,
        record: Option<IndexRecordOption>,
    ) -> anyhow::Result<Option<Self>> {
        if indexed {
            Ok(Some(TextIndexingOptions {
                tokenizer: tokenizer.unwrap_or_else(QuickwitTextTokenizer::raw),
                record: record.unwrap_or(IndexRecordOption::Basic),
                fieldnorms: false,
            }))
        } else {
            if tokenizer.is_some() || record.is_some() {
                bail!("`record` and `tokenizer` parameters are allowed only if indexed is true")
            }
            Ok(None)
        }
    }

    fn from_parts_concatenate(
        tokenizer: Option<QuickwitTextTokenizer>,
        record: Option<IndexRecordOption>,
    ) -> anyhow::Result<Self> {
        let text_index_options_opt = Self::from_parts_text(true, tokenizer, record, false)?;
        let text_index_options = text_index_options_opt.expect("concatenate field must be indexed");
        Ok(text_index_options)
    }

    fn to_parts_text(
        this: Option<Self>,
    ) -> (
        bool, // indexed

View on GitHub (pinned to a39730c5cd)

Solutions

  1. Remove `record` and `tokenizer` from the json field mapping when `indexed: false`.
  2. Set `indexed: true` if tokenization/record options are required.
  3. Review mapping templates to drop indexing options for unindexed fields.

Example fix

// before
{name: "attrs", type: "json", indexed: false, tokenizer: "raw", record: "basic"}
// after
{name: "attrs", type: "json", indexed: false}
Defensive patterns

Strategy: validation

Validate before calling

fn json_mapping_is_consistent(f: &serde_json::Value) -> bool {
    if f.get("indexed").and_then(|v| v.as_bool()) == Some(false) {
        !(f.get("tokenizer").is_some() || f.get("record").is_some())
    } else { true }
}

Try / catch

match create_index_result {
    Err(e) if e.to_string().contains("`record` and `tokenizer` parameters are allowed only if indexed is true") => {
        eprintln!("Drop record/tokenizer from unindexed json fields");
    }
    other => other?,
}

Prevention

When it happens

Trigger: A field mapping like `{type: "json", indexed: false, tokenizer: "raw"}` or with `record: basic` — from_parts_json bails since search options require an indexed field.

Common situations: Copy-pasting tokenizer options from a text mapping onto a json field that was toggled to indexed:false; generated mappings that always include default record/tokenizer values; users trying to control tokenization of unindexed json fields.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


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