quickwit-oss/quickwit · error

regex query with multiple fields is not supported

Error message

regex query with multiple fields is not supported

What it means

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.

Solutions

  1. Qualify the regex with a single field: `body:/ok.*/`.
  2. Limit default search fields to one for unfielded regex usage.
  3. Construct the RegexQuery AST explicitly with the intended field.

Example fix

// before
parse_user_query_with_default_fields("/ok.*/", &["title", "body"])
// after
parse_user_query_with_default_fields("body:/ok.*/", &["title", "body"])
Defensive patterns

Strategy: validation

Validate before calling

if looks_like_regex(query_str) && !query_str.contains(':') && default_search_fields.len() > 1 {
    return Err("unfielded regex query ambiguous with multiple default fields");
}

Try / catch

match parse_user_query(q) {
    Err(e) if e.to_string().contains("regex query with multiple fields") => {
        // retry with explicit field prefix
    }
    r => r?,
}

Prevention

When it happens

Trigger: Parsing an unfielded regex query string while default_search_fields has 2+ entries, e.g. `parse_user_query("/ok.*/")` with defaults ["title", "body"].

Common situations: Search setups with several default fields; users relying on shorthand regex syntax after defaults were broadened from one field to several.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of quickwit-oss/quickwit@a39730c5cd (2026-09-08). Data as JSON: /api/errors/c612f90569418bb1. Report an issue: GitHub.

Appendix: source

Thrown at quickwit/quickwit-query/src/query_ast/user_input_query.rs:184

                }
                let mut terms_per_field: HashMap<String, BTreeSet<String>> = Default::default();
                let terms: BTreeSet<String> = elements.into_iter().collect();
                for field in field_names {
                    terms_per_field.insert(field.to_string(), terms.clone());
                }
                let term_set_query = query_ast::TermSetQuery { terms_per_field };
                Ok(term_set_query.into())
            }
            UserInputLeaf::Exists { field } => Ok(FieldPresenceQuery { field }.into()),
            UserInputLeaf::Regex { field, pattern } => {
                let field = if let Some(field) = field {
                    field
                } else if default_search_fields.len() == 1 {
                    default_search_fields[0].clone()
                } else if default_search_fields.is_empty() {
                    bail!("regex query without field is not supported");
                } else {
                    bail!("regex query with multiple fields is not supported");
                };
                let regex_query = query_ast::RegexQuery {
                    field,
                    regex: pattern,
                };
                Ok(regex_query.into())
            }
        },
        UserInputAst::Boost(underlying, boost) => {
            let query_ast = convert_user_input_ast_to_query_ast(
                *underlying,
                default_occur,
                default_search_fields,
                lenient,
            )?;
            let boost: NotNaNf32 = (boost.into_inner() as f32)
                .try_into()
                .map_err(|err_msg: &str| anyhow::anyhow!(err_msg))?;

View on GitHub (pinned to a39730c5cd)