{"record":{"id":"679baa8c8940c2ed","repo":"quickwit-oss/quickwit","slug":"the-snippet-field-must-be-of-type-str-got","errorCode":null,"errorMessage":"the snippet field `{}` must be of type `Str`, got `{}`","messagePattern":"the snippet field `(.+?)` must be of type `Str`, got `(.+?)`","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-search/src/root.rs","lineNumber":339,"sourceCode":"fn validate_requested_snippet_fields(\n    schema: &Schema,\n    snippet_fields: &[String],\n) -> anyhow::Result<()> {\n    for field_name in snippet_fields {\n        let field_entry = schema\n            .get_field(field_name)\n            .map(|field| schema.get_field_entry(field))?;\n        match field_entry.field_type() {\n            FieldType::Str(text_options) => {\n                if !text_options.is_stored() {\n                    return Err(anyhow::anyhow!(\n                        \"the snippet field `{}` must be stored\",\n                        field_name\n                    ));\n                }\n            }\n            other => {\n                return Err(anyhow::anyhow!(\n                    \"the snippet field `{}` must be of type `Str`, got `{}`\",\n                    field_name,\n                    other.value_type().name()\n                ));\n            }\n        }\n    }\n    Ok(())\n}\n\nfn simplify_search_request_for_scroll_api(req: &SearchRequest) -> crate::Result<SearchRequest> {\n    if req.search_after.is_some() {\n        return Err(SearchError::InvalidArgument(\n            \"search_after cannot be used in a scroll context\".to_string(),\n        ));\n    }\n\n    // We do not mutate","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-search/src/root.rs#L321-L357","documentation":"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.","triggerScenarios":"Calling search with snippet_fields containing a field whose schema type is not text (e.g. u64, datetime, json, bytes).","commonSituations":"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.","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)."],"exampleFix":"// before\n{\"search\": [\"status\"], \"snippet_fields\": [\"status\"]} // status is u64\n// after\n{\"search\": [\"status\"], \"snippet_fields\": [\"message\"]} // message is text","handlingStrategy":"validation","validationCode":"fn only_text_fields(schema: &Schema, fields: &[String]) -> Vec<String> {\n    fields.iter().filter(|f| {\n        schema.get_field(f).map(|fd| matches!(schema.get_field_entry(fd).field_type(), FieldType::Str(_))).unwrap_or(false)\n    }).cloned().collect()\n}","typeGuard":"fn is_str_field(schema: &Schema, name: &str) -> bool {\n    schema.get_field(name).map(|f| matches!(schema.get_field_entry(f).field_type(), FieldType::Str(_))).unwrap_or(false)\n}","tryCatchPattern":"match search(req.clone()).await {\n    Err(e) if e.to_string().contains(\"must be of type `Str`\") => {\n        let mut req = req; req.snippet_fields = vec![]; search(req).await\n    }\n    r => r,\n}","preventionTips":["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"],"tags":["rust","search","snippets","schema","type-mismatch"],"backgroundTag":"type-mismatch","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}