{"record":{"id":"42f71e04fed900aa","repo":"quickwit-oss/quickwit","slug":"invalid-named-document-there-are-more-than-1-valu","errorCode":null,"errorMessage":"invalid named document. there are more than 1 value associated to the `{key}` field","messagePattern":"invalid named document\\. there are more than 1 value associated to the `(.+?)` field","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-doc-mapper/src/doc_mapper/doc_mapper_impl.rs","lineNumber":409,"sourceCode":"                &self.default_search_field_names,\n            )\n            .field(\"timestamp_field_name\", &self.timestamp_field_name())\n            // TODO: complete it.\n            .finish()\n    }\n}\n\nfn extract_single_obj(\n    doc: &mut BTreeMap<String, Vec<TantivyValue>>,\n    key: &str,\n) -> anyhow::Result<Option<serde_json::Map<String, JsonValue>>> {\n    let mut values = if let Some(values) = doc.remove(key) {\n        values\n    } else {\n        return Ok(None);\n    };\n    if values.len() > 1 {\n        bail!(\n            \"invalid named document. there are more than 1 value associated to the `{key}` field\"\n        );\n    }\n    match values.pop() {\n        Some(TantivyValue::Object(dynamic_json_obj)) => Ok(Some(\n            dynamic_json_obj\n                .into_iter()\n                .map(|(key, val)| (key, tantivy_value_to_json(val)))\n                .collect(),\n        )),\n        Some(_) => {\n            bail!(\"the `{key}` value has to be a json object\");\n        }\n        None => Ok(None),\n    }\n}\n\nimpl DocMapper {","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-doc-mapper/src/doc_mapper/doc_mapper_impl.rs#L391-L427","documentation":"When converting a tantivy NamedFieldDocument back to JSON (doc_to_json), each field key may carry only a single value that must be a JSON object. If the multivalue slot for a key holds more than one value, the function cannot pick one and bails. This indicates the document shape violates the expected single-object-per-key contract used for dynamic/_source-style extraction.","triggerScenarios":"Calling doc_to_json / extract_single_obj on a NamedFieldDocument where the Vec<TantivyValue> for a given key contains 2+ entries, e.g. a nested object field that was stored twice under the same key.","commonSituations":"Displaying stored documents after search; documents whose dynamic JSON subfields were indexed such that the same key maps to multiple stored values; unexpected tantivy document produced by a doc-mapper bug or a schema where an object field and a scalar share the same key.","solutions":["Inspect the document and ensure each key maps to at most one stored value; avoid indexing the same object field path twice.","If a schema change is involved, re-index with a schema where object field names do not collide with other fields sharing the same path prefix.","If you own the producer, deduplicate values for that key before indexing."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"// ensure the stored value list has at most one element before conversion\nfn single_value(doc: &NamedFieldDocument, key: &str) -> Option<&TantivyValue> {\n    let values = doc.named_doc.get(key)?;\n    if values.len() == 1 { values.first() } else { None }\n}","tryCatchPattern":"match doc_to_json(&mapper, doc, /*expand_dots*/ true) {\n    Err(e) if e.to_string().contains(\"more than 1 value associated\") => {\n        log::warn!(\"skipping malformed document for _source rendering: {e}\");\n    }\n    other => other?,\n}","preventionTips":["Do not index the same object path twice under different mapping entries.","Keep object field names distinct from sibling scalar field names.","Add round-trip tests that convert indexed documents back to JSON for object-heavy schemas."],"tags":["document","json","rust","search"],"backgroundTag":"internal-invariant-violation","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}