quickwit-oss/quickwit · error

regex query without field is not supported

Error message

regex query without field is not supported

What it means

For UserInputLeaf::Regex, the field must come from the leaf itself or be uniquely inferable from default_search_fields. With no field on the leaf and an empty default search field list, there is no target for the regex match, so the conversion bails with this error.

Solutions

  1. Add an explicit field prefix: `message:/foo.*bar/`.
  2. Configure a default search field for the search request or index.
  3. Build a query_ast::RegexQuery directly with the field set.

Example fix

// before
parse_user_query("/err.*timeout/")?
// after
parse_user_query("message:/err.*timeout/")?
Defensive patterns

Strategy: validation

Validate before calling

if looks_like_regex(query_str) && !query_str.contains(':') && default_search_fields.is_empty() {
    return Err("regex query needs an explicit field or a default search field");
}

Try / catch

match parse_user_query(q) {
    Err(e) if e.to_string().contains("regex query without field") => {
        // retry with field-qualified regex
    }
    r => r?,
}

Prevention

When it happens

Trigger: Parsing an unfielded regex query string like `/foo.*bar/` (no `field:` prefix) while no default search field is configured, via parse_user_query or nested conversion.

Common situations: Users pasting Lucene regex queries into a search box on indexes without a default field; programmatic query parsing that omits default_search_fields.

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/8d247aec5ab612dc. Report an issue: GitHub.

Appendix: source

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

                if field_names.is_empty() {
                    anyhow::bail!("set query need to target a specific field");
                }
                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)

View on GitHub (pinned to a39730c5cd)