{"record":{"id":"c612f90569418bb1","repo":"quickwit-oss/quickwit","slug":"regex-query-with-multiple-fields-is-not-supported","errorCode":null,"errorMessage":"regex query with multiple fields is not supported","messagePattern":"regex query with multiple fields is not supported","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-query/src/query_ast/user_input_query.rs","lineNumber":184,"sourceCode":"                }\n                let mut terms_per_field: HashMap<String, BTreeSet<String>> = Default::default();\n                let terms: BTreeSet<String> = elements.into_iter().collect();\n                for field in field_names {\n                    terms_per_field.insert(field.to_string(), terms.clone());\n                }\n                let term_set_query = query_ast::TermSetQuery { terms_per_field };\n                Ok(term_set_query.into())\n            }\n            UserInputLeaf::Exists { field } => Ok(FieldPresenceQuery { field }.into()),\n            UserInputLeaf::Regex { field, pattern } => {\n                let field = if let Some(field) = field {\n                    field\n                } else if default_search_fields.len() == 1 {\n                    default_search_fields[0].clone()\n                } else if default_search_fields.is_empty() {\n                    bail!(\"regex query without field is not supported\");\n                } else {\n                    bail!(\"regex query with multiple fields is not supported\");\n                };\n                let regex_query = query_ast::RegexQuery {\n                    field,\n                    regex: pattern,\n                };\n                Ok(regex_query.into())\n            }\n        },\n        UserInputAst::Boost(underlying, boost) => {\n            let query_ast = convert_user_input_ast_to_query_ast(\n                *underlying,\n                default_occur,\n                default_search_fields,\n                lenient,\n            )?;\n            let boost: NotNaNf32 = (boost.into_inner() as f32)\n                .try_into()\n                .map_err(|err_msg: &str| anyhow::anyhow!(err_msg))?;","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-query/src/query_ast/user_input_query.rs#L166-L202","documentation":"Like the range case, an unfielded regex leaf can only be resolved when exactly one default search field exists. If multiple default search fields are configured, applying the regex to all of them is unsupported, and the conversion bails rather than guessing.","triggerScenarios":"Parsing an unfielded regex query string while default_search_fields has 2+ entries, e.g. `parse_user_query(\"/ok.*/\")` with defaults [\"title\", \"body\"].","commonSituations":"Search setups with several default fields; users relying on shorthand regex syntax after defaults were broadened from one field to several.","solutions":["Qualify the regex with a single field: `body:/ok.*/`.","Limit default search fields to one for unfielded regex usage.","Construct the RegexQuery AST explicitly with the intended field."],"exampleFix":"// before\nparse_user_query_with_default_fields(\"/ok.*/\", &[\"title\", \"body\"])\n// after\nparse_user_query_with_default_fields(\"body:/ok.*/\", &[\"title\", \"body\"])","handlingStrategy":"validation","validationCode":"if looks_like_regex(query_str) && !query_str.contains(':') && default_search_fields.len() > 1 {\n    return Err(\"unfielded regex query ambiguous with multiple default fields\");\n}","typeGuard":null,"tryCatchPattern":"match parse_user_query(q) {\n    Err(e) if e.to_string().contains(\"regex query with multiple fields\") => {\n        // retry with explicit field prefix\n    }\n    r => r?,\n}","preventionTips":["Keep a single default search field when regex shorthand is used.","Require field-qualified regexes in programmatic query generation.","Review index configs where default_search_fields grew beyond one entry."],"tags":["regex-query","user-input","ambiguous-fields"],"backgroundTag":"missing-required-argument","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}