{"record":{"id":"8ab5cee96790b77e","repo":"quickwit-oss/quickwit","slug":"the-snippet-field-must-be-stored","errorCode":null,"errorMessage":"the snippet field `{}` must be stored","messagePattern":"the snippet field `(.+?)` must be stored","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-search/src/root.rs","lineNumber":332,"sourceCode":"        } else {\n            sort_field_is_datetime.insert(sort_field.field_name.to_string(), false);\n        }\n    }\n    Ok(())\n}\n\nfn 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> {","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-search/src/root.rs#L314-L350","documentation":"When a search request asks for snippets on a field, validation checks the schema entry. Snippet generation requires the original text, so the field's text options must have stored=true. If a Str field used as snippet field is not stored, this error is returned before executing the search.","triggerScenarios":"Calling search (REST or gRPC) with snippet_fields (or snippet_fields_opt) containing a field name whose schema definition is a Str field with indexing options that do not store the field.","commonSituations":"Adding snippet_fields to a request for a field defined only as indexed-not-stored; schema changed to drop stored=true after snippet support was added to client code; copy-pasted snippet field config from a different index.","solutions":["Set stored: true on the field's text field options in the index config and reindex (or update the index config via the API).","Remove that field from the request's snippet_fields list.","Choose a different stored Str field for snippet generation."],"exampleFix":"// before (index config)\n{\"name\": \"body\", \"type\": \"text\", \"indexed\": true, \"stored\": false}\n// after\n{\"name\": \"body\", \"type\": \"text\", \"indexed\": true, \"stored\": true}","handlingStrategy":"validation","validationCode":"fn snippet_fields_are_stored(schema: &Schema, fields: &[String]) -> Result<(), String> {\n    for f in fields {\n        let entry = schema.get_field_entry(schema.get_field(f).map_err(|_| format!(\"unknown field {f}\"))?);\n        if let FieldType::Str(opts) = entry.field_type() {\n            if !opts.is_stored() { return Err(format!(\"snippet field `{f}` must be stored\")); }\n        }\n    }\n    Ok(())\n}","typeGuard":"fn is_stored_str_field(schema: &Schema, name: &str) -> bool {\n    schema.get_field(name).map(|f| matches!(schema.get_field_entry(f).field_type(), FieldType::Str(o) if o.is_stored())).unwrap_or(false)\n}","tryCatchPattern":"match search_request(snippet_fields).await {\n    Err(e) if e.to_string().contains(\"must be stored\") => search_request(&[]).await, // retry without snippets\n    r => r,\n}","preventionTips":["Mark fields used for UI highlighting as stored: true in the index config","Filter snippet_fields against the schema before sending requests","Update request templates when the index schema changes"],"tags":["rust","search","snippets","schema"],"backgroundTag":"schema-validation-failed","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"}