quickwit-oss/tantivy · error

the JSON field does not support custom field types

Error message

the JSON field does not support custom field types

What it means

Custom leaf values (custom ReferenceValue types) are rejected by the JSON dynamic field columnar writer. The JSON field only supports a fixed set of leaf types; anything Custom is explicitly unimplemented. This surfaces as a panic, not a recoverable error.

Source

Thrown at src/fastfield/writer.rs:354

            }
            ReferenceValueLeaf::Facet(_) => {
                unimplemented!("Facet support in dynamic fields is not yet implemented")
            }
            ReferenceValueLeaf::Bytes(_) => {
                // TODO: This can be re added once it is added to the JSON Utils section as well.
                // columnar_writer.record_bytes(doc, json_path_writer.as_str(), val);
                unimplemented!("Bytes support in dynamic fields is not yet implemented")
            }
            ReferenceValueLeaf::IpAddr(_) => {
                unimplemented!("IP address support in dynamic fields is not yet implemented")
            }
            ReferenceValueLeaf::PreTokStr(_) => {
                unimplemented!(
                    "Pre-tokenized string support in dynamic fields is not yet implemented"
                )
            }
            ReferenceValueLeaf::Custom(_) => {
                unimplemented!("the JSON field does not support custom field types")
            }
        },
        ReferenceValue::Array(elements) => {
            for el in elements {
                record_json_value_to_columnar_writer(
                    doc,
                    el,
                    remaining_depth_limit,
                    json_path_writer,
                    columnar_writer,
                    tokenizer,
                );
            }
        }
        ReferenceValue::Object(object) => {
            record_json_obj_to_columnar_writer::<V>(
                doc,
                object,

View on GitHub (pinned to b5d8deb80c)

Solutions

  1. Do not put custom field types inside JSON dynamic fields; use a dedicated field.
  2. Flatten the custom type into a supported leaf (string, u64, i64, f64, bool, date) before adding to the JSON object.
  3. Encode the custom value into a supported representation (e.g. bytes stored elsewhere).
  4. Contribute/patch support for custom types upstream.

Example fix

// before
json_field.add_json_object(doc, json!({"geo": custom_value})); // Custom leaf -> panic
// after
json_field.add_json_object(doc, json!({"geo": custom_value.to_string()})); // supported leaf
Defensive patterns

Strategy: validation

Validate before calling

fn is_supported_leaf(v: &ReferenceValueLeaf) -> bool {
    !matches!(v, ReferenceValueLeaf::Custom(_) | ReferenceValueLeaf::IpAddr(_) | ReferenceValueLeaf::PreTokStr(_) | ReferenceValueLeaf::Bytes(_))
}

Type guard

fn is_custom_leaf(v: &ReferenceValueLeaf) -> bool {
    matches!(v, ReferenceValueLeaf::Custom(_))
}

Prevention

When it happens

Trigger: record_json_value_to_columnar_writer encountering ReferenceValueLeaf::Custom(_) — i.e. indexing a JSON dynamic field whose value is a custom field type, including through Array elements.

Common situations: Extending tantivy with a custom fast-field type and attempting to place it inside JSON dynamic fields; third-party plugins inserting custom leaf values into json fields.

Related errors


AI-assisted analysis of quickwit-oss/tantivy@b5d8deb80c (2026-09-05). Data as JSON: /api/errors/8868278eb1cd037e. Report an issue: GitHub.