quickwit-oss/tantivy · error

Facet support in dynamic fields is not yet implemented

Error message

Facet support in dynamic fields is not yet implemented

What it means

record_json_value_to_columnar_writer records JSON leaves into a columnar (fast-field) writer and panics with unimplemented!() for Facet leaves. Facet values cannot yet be stored as fast-field columns for dynamic JSON fields; facets must use schema-declared facet fields.

Source

Thrown at src/fastfield/writer.rs:338

                    json_path_writer.as_str(),
                    NumericalValue::from(val),
                );
            }
            ReferenceValueLeaf::F64(val) => {
                columnar_writer.record_numerical(
                    doc,
                    json_path_writer.as_str(),
                    NumericalValue::from(val),
                );
            }
            ReferenceValueLeaf::Bool(val) => {
                columnar_writer.record_bool(doc, json_path_writer.as_str(), val);
            }
            ReferenceValueLeaf::Date(val) => {
                columnar_writer.record_datetime(doc, json_path_writer.as_str(), val);
            }
            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")
            }
        },

View on GitHub (pinned to b5d8deb80c)

Solutions

  1. Declare the field with FacetOptions in the schema so facets bypass the JSON columnar path
  2. Convert facet paths to plain strings in the JSON field if aggregation is not needed
  3. Remove facet values from dynamic JSON documents before indexing

Example fix

// before
json_obj.insert("tags", Value::Facet(facet));
// after
let tags = schema_builder.add_facet_field("tags", FacetOptions::default());
Defensive patterns

Strategy: validation

Validate before calling

fn json_obj_has_facet_leaves(obj: &tantivy::schema::OwnedValue) -> bool {
    // facets must be indexed via schema-declared facet fields, not dynamic JSON
    matches!(obj, tantivy::schema::OwnedValue::Facet(_))
}
// screen values before add_document

Type guard

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

Try / catch

let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| writer.commit()));
if result.is_err() { eprintln!("segment write failed: facet inside dynamic JSON fast fields"); }

Prevention

When it happens

Trigger: Writing a segment that contains a dynamic JSON field whose value is a Facet leaf — reached via record_json_obj_to_columnar_writer during segment writing.

Common situations: Indexing JSON documents containing facet-typed values; migrating facet fields into dynamic JSON fields.

Related errors


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