quickwit-oss/quickwit · error
the snippet field `{}` must be of type `Str`, got `{}`
Error message
the snippet field `{}` must be of type `Str`, got `{}` What it means
Snippet fields must be of type Str (text). If the requested snippet field exists in the schema but has a non-Str field type (u64, bytes, json, etc.), validation rejects it with this error naming the actual type. Snippet generation only supports text content.
Source
Thrown at quickwit/quickwit-search/src/root.rs:339
fn validate_requested_snippet_fields(
schema: &Schema,
snippet_fields: &[String],
) -> anyhow::Result<()> {
for field_name in snippet_fields {
let field_entry = schema
.get_field(field_name)
.map(|field| schema.get_field_entry(field))?;
match field_entry.field_type() {
FieldType::Str(text_options) => {
if !text_options.is_stored() {
return Err(anyhow::anyhow!(
"the snippet field `{}` must be stored",
field_name
));
}
}
other => {
return Err(anyhow::anyhow!(
"the snippet field `{}` must be of type `Str`, got `{}`",
field_name,
other.value_type().name()
));
}
}
}
Ok(())
}
fn simplify_search_request_for_scroll_api(req: &SearchRequest) -> crate::Result<SearchRequest> {
if req.search_after.is_some() {
return Err(SearchError::InvalidArgument(
"search_after cannot be used in a scroll context".to_string(),
));
}
// We do not mutateView on GitHub (pinned to a39730c5cd)
Solutions
- Remove the non-text field from snippet_fields; snippets are only supported for text fields.
- Only pass fields programmatically filtered to schema field type Str.
- If snippets on the field are truly needed, change the field type to text in the index config (requires reindexing).
Example fix
// before
{"search": ["status"], "snippet_fields": ["status"]} // status is u64
// after
{"search": ["status"], "snippet_fields": ["message"]} // message is text Defensive patterns
Strategy: validation
Validate before calling
fn only_text_fields(schema: &Schema, fields: &[String]) -> Vec<String> {
fields.iter().filter(|f| {
schema.get_field(f).map(|fd| matches!(schema.get_field_entry(fd).field_type(), FieldType::Str(_))).unwrap_or(false)
}).cloned().collect()
} Type guard
fn is_str_field(schema: &Schema, name: &str) -> bool {
schema.get_field(name).map(|f| matches!(schema.get_field_entry(f).field_type(), FieldType::Str(_))).unwrap_or(false)
} Try / catch
match search(req.clone()).await {
Err(e) if e.to_string().contains("must be of type `Str`") => {
let mut req = req; req.snippet_fields = vec![]; search(req).await
}
r => r,
} Prevention
- Only request snippets for text (Str) fields
- Keep snippet field lists in sync with the schema
- Validate field types client-side using the index metadata API
When it happens
Trigger: Calling search with snippet_fields containing a field whose schema type is not text (e.g. u64, datetime, json, bytes).
Common situations: Client UI sends the same field list for both retrieval and snippets; schema field type changed (e.g. text to json) while request templates still request snippets on it.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- the snippet field `{}` must be stored
- unknown tokenizer `{}` for field `{}`
- invalid named document. there are more than 1 value associat
- the `{key}` value has to be a json object
- `record`, `tokenizer`, and `fieldnorms` parameters are allow
AI-assisted analysis of quickwit-oss/quickwit@a39730c5cd (2026-09-08).
Data as JSON: /api/errors/679baa8c8940c2ed.
Report an issue: GitHub.