quickwit-oss/quickwit · error · anyhow::Error
invalid named document. there are more than 1 value associat
Error message
invalid named document. there are more than 1 value associated to the `{key}` field What it means
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.
Source
Thrown at quickwit/quickwit-doc-mapper/src/doc_mapper/doc_mapper_impl.rs:409
&self.default_search_field_names,
)
.field("timestamp_field_name", &self.timestamp_field_name())
// TODO: complete it.
.finish()
}
}
fn extract_single_obj(
doc: &mut BTreeMap<String, Vec<TantivyValue>>,
key: &str,
) -> anyhow::Result<Option<serde_json::Map<String, JsonValue>>> {
let mut values = if let Some(values) = doc.remove(key) {
values
} else {
return Ok(None);
};
if values.len() > 1 {
bail!(
"invalid named document. there are more than 1 value associated to the `{key}` field"
);
}
match values.pop() {
Some(TantivyValue::Object(dynamic_json_obj)) => Ok(Some(
dynamic_json_obj
.into_iter()
.map(|(key, val)| (key, tantivy_value_to_json(val)))
.collect(),
)),
Some(_) => {
bail!("the `{key}` value has to be a json object");
}
None => Ok(None),
}
}
impl DocMapper {View on GitHub (pinned to a39730c5cd)
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.
Defensive patterns
Strategy: try-catch
Type guard
// ensure the stored value list has at most one element before conversion
fn single_value(doc: &NamedFieldDocument, key: &str) -> Option<&TantivyValue> {
let values = doc.named_doc.get(key)?;
if values.len() == 1 { values.first() } else { None }
} Try / catch
match doc_to_json(&mapper, doc, /*expand_dots*/ true) {
Err(e) if e.to_string().contains("more than 1 value associated") => {
log::warn!("skipping malformed document for _source rendering: {e}");
}
other => other?,
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- the `{key}` value has to be a json object
- Encountered unknown command: code {other}
- unknown tokenizer `{}` for field `{}`
- failed to assign search jobs: there are no available searche
- failed to assign search jobs: there are no searcher nodes ca
AI-assisted analysis of quickwit-oss/quickwit@a39730c5cd (2026-09-08).
Data as JSON: /api/errors/42f71e04fed900aa.
Report an issue: GitHub.