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

index_json_value panics via unimplemented!() when the JSON leaf is a Custom value type. Dynamic JSON fields do not support custom field types by design; custom types require dedicated schema plumbing. The panic is an explicit not-implemented marker.

Source

Thrown at src/core/json_utils.rs:231

                term_buffer.append_type_and_fast_value(val);
                postings_writer.subscribe(doc, 0u32, term_buffer, ctx);
            }
            ReferenceValueLeaf::PreTokStr(_) => {
                unimplemented!(
                    "Pre-tokenized string support in dynamic fields is not yet implemented"
                )
            }
            ReferenceValueLeaf::Bytes(_) => {
                unimplemented!("Bytes support in dynamic fields is not yet implemented")
            }
            ReferenceValueLeaf::Facet(_) => {
                unimplemented!("Facet support in dynamic fields is not yet implemented")
            }
            ReferenceValueLeaf::IpAddr(_) => {
                unimplemented!("IP address support in dynamic fields is not yet implemented")
            }
            ReferenceValueLeaf::Custom(_) => {
                unimplemented!("the JSON field does not support custom field types")
            }
        },
        ReferenceValue::Array(elements) => {
            for val in elements {
                index_json_value(
                    doc,
                    val,
                    text_analyzer,
                    term_buffer,
                    json_path_writer,
                    postings_writer,
                    ctx,
                    positions_per_path,
                );
            }
        }
        ReferenceValue::Object(object) => {
            index_json_object::<V>(

View on GitHub (pinned to b5d8deb80c)

Solutions

  1. Ensure values routed to JSON fields are plain JSON scalars/arrays/objects
  2. Handle custom types in a dedicated typed field rather than dynamic JSON indexing
  3. Convert the custom value into a supported representation before indexing

Example fix

// before
json_obj.insert("x", custom_value);
// after
json_obj.insert("x", Value::Str(custom_value.to_string()));
Defensive patterns

Strategy: validation

Validate before calling

fn ensure_plain_json(v: &serde_json::Value) -> Result<(), &'static str> {
    match v {
        serde_json::Value::Null | serde_json::Value::Bool(_) | serde_json::Value::Number(_)
        | serde_json::Value::String(_) => Ok(()),
        serde_json::Value::Array(a) => a.iter().try_for_each(ensure_plain_json),
        serde_json::Value::Object(o) => o.values().try_for_each(ensure_plain_json),
    }
}

Type guard

fn is_custom_leaf(v: &tantivy::schema::Value) -> bool {
    matches!(v.as_value(), tantivy::schema::ReferenceValueLeaf::Custom(_))
}

Try / catch

let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| index_writer.add_document(doc)));
if result.is_err() { eprintln!("JSON field contained a custom value type"); }

Prevention

When it happens

Trigger: Indexing a document where a JSON field's leaf value is a Custom(...) ReferenceValue via index_document.

Common situations: Custom integrations or plugins pushing bespoke value types through the generic JSON indexing path; test fixtures reusing typed-field values inside JSON objects.

Related errors


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