quickwit-oss/quickwit · error

set query need to target a specific field

Error message

set query need to target a specific field

What it means

A UserInputLeaf::Set (membership test like `IN {a b c}`) expands to term queries over one or more target fields. The field is either explicit or taken from default_search_fields; when both are absent the field name list is empty and the conversion bails because a set query must target at least one concrete field.

Solutions

  1. Prefix the set with a field: `level IN {error warn}` (or the syntax Quickwit expects with field).
  2. Supply a default search field so unfielded set queries resolve.
  3. Rewrite as an explicit boolean/term query AST targeting the field.

Example fix

// before
parse_user_query("IN {error warn}")?
// after
parse_user_query("level:IN {error warn}")?
Defensive patterns

Strategy: validation

Validate before calling

if is_set_query(query_str) && !query_str.contains(':') && default_search_fields.is_empty() {
    return Err("set query requires an explicit field");
}

Try / catch

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

Prevention

When it happens

Trigger: Parsing a set-style query leaf without a field prefix while default_search_fields is empty, e.g. `parse_user_query("IN {apple banana}")` with no defaults.

Common situations: Users entering Elasticsearch-like IN/set syntax in the Quickwit UI without a field; search APIs invoked without default search field configuration.

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/49f2382542a909ca. Report an issue: GitHub.

Appendix: source

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

                        Bound::Excluded(JsonLiteral::String(user_text))
                    }
                    UserInputBound::Unbounded => Bound::Unbounded,
                };
                let range_query = query_ast::RangeQuery {
                    field,
                    lower_bound: convert_bound(lower),
                    upper_bound: convert_bound(upper),
                };
                Ok(range_query.into())
            }
            UserInputLeaf::Set { field, elements } => {
                let field_names: Vec<String> = if let Some(field) = field.as_ref() {
                    vec![field.to_string()]
                } else {
                    default_search_fields.to_vec()
                };
                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 {

View on GitHub (pinned to a39730c5cd)