{"record":{"id":"2be5cb6d840ef357","repo":"quickwit-oss/quickwit","slug":"field-does-not-exist","errorCode":null,"errorMessage":"field does not exist: {}","messagePattern":"field does not exist: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-doc-mapper/src/query_builder.rs","lineNumber":258,"sourceCode":"    fn new(schema: &'a Schema) -> Self {\n        ExtractTermSetFields {\n            term_dict_fields_to_warm_up: HashSet::new(),\n            schema,\n        }\n    }\n}\n\nimpl<'a> QueryAstVisitor<'a> for ExtractTermSetFields<'_> {\n    type Err = anyhow::Error;\n\n    fn visit_term_set(&mut self, term_set_query: &'a TermSetQuery) -> anyhow::Result<()> {\n        for field in term_set_query.terms_per_field.keys() {\n            if let Some((field, _field_entry, _path)) =\n                find_field_or_hit_dynamic(field, self.schema)\n            {\n                self.term_dict_fields_to_warm_up.insert(field);\n            } else {\n                anyhow::bail!(\"field does not exist: {}\", field);\n            }\n        }\n        Ok(())\n    }\n}\n\nfn extract_term_set_query_fields(\n    query_ast: &QueryAst,\n    schema: &Schema,\n) -> anyhow::Result<HashSet<Field>> {\n    let mut visitor = ExtractTermSetFields::new(schema);\n    visitor.visit(query_ast)?;\n    Ok(visitor.term_dict_fields_to_warm_up)\n}\n\n/// Converts a `prefix` term into the equivalent term range.\n///\n/// The resulting range is `[prefix, next_prefix)`, that is:","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-doc-mapper/src/query_builder.rs#L240-L276","documentation":"While planning a TermSetQuery, the query builder warms up term dictionaries for each field named in terms_per_field; if a field name does not resolve in the index schema (even with dynamic-field fallback), the query cannot be executed and is rejected.","triggerScenarios":"Executing a search with a term set query `{\"term_set\": {\"field\": \"foo\", \"terms\": [...]}}` where `foo` is not in the index schema and is not matched by dynamic mapping, via visit_term_set in QueryBuilder.","commonSituations":"Typos in field names in search queries; querying an index whose schema changed (field renamed/removed); clients reusing query templates across indexes with different schemas; relying on a dynamic field that was never ingested so it is not in the schema.","solutions":["Fix the field name in the query to match a field in the index schema (check with the describe-index API).","Add the field to the index mapping and re-index or use dynamic mode.","Verify the query targets the correct index whose schema actually contains the field."],"exampleFix":"// before\ncurl -X POST .../search -d '{\"query\": \"foo:[a TO b]\", ...}' with term_set on missing field\n// after\n{\"term_set\": {\"field\": \"message\", \"terms\": [\"error\", \"warn\"]}}  // 'message' exists in schema","handlingStrategy":"try-catch","validationCode":"// before querying\nlet schema = client.index(index_id).await?.descriptor().doc_mapping; // or describe-index\nif !schema_field_names.contains(&field_name) {\n    return Err(format!(\"field `{field_name}` not in index schema\"));\n}","typeGuard":"fn field_exists(schema_fields: &[String], field: &str) -> bool {\n    schema_fields.iter().any(|f| f == field)\n}","tryCatchPattern":"match resp {\n    Err(e) if e.to_string().starts_with(\"field does not exist\") => {\n        // correct the field name or refresh schema and retry once\n    }\n    other => other?,\n}","preventionTips":["Fetch the index schema (describe-index / _describe) before building term set queries.","Avoid hardcoding field names in shared query templates across indexes.","Re-check queries after any mapping rename/removal."],"tags":["search","query","schema"],"backgroundTag":"entity-not-found","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}