{"record":{"id":"d62deced3a186749","repo":"spring-projects/spring-ai","slug":"field-s-is-not-a-text-field","errorCode":null,"errorMessage":"Field '%s' is not a TEXT field","messagePattern":"Field '(.+?)' is not a TEXT field","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vector-stores/spring-ai-redis-store/src/main/java/org/springframework/ai/vectorstore/redis/RedisVectorStore.java","lineNumber":789,"sourceCode":"\t\tif (normalizedFieldName.equals(this.contentFieldName)) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Check if it's a metadata field with TEXT type\n\t\tboolean isTextField = this.metadataFields.stream()\n\t\t\t.anyMatch(field -> field.name().equals(normalizedFieldName) && field.fieldType() == FieldType.TEXT);\n\n\t\tif (!isTextField) {\n\t\t\t// Log detailed metadata fields for debugging\n\t\t\tif (logger.isDebugEnabled()) {\n\t\t\t\tlogger.debug(\"Field not found as TEXT: '\" + normalizedFieldName + \"'\");\n\t\t\t\tlogger.debug(\"Content field name: '\" + this.contentFieldName + \"'\");\n\t\t\t\tlogger.debug(\"Available TEXT fields: \" + this.metadataFields.stream()\n\t\t\t\t\t.filter(field -> field.fieldType() == FieldType.TEXT)\n\t\t\t\t\t.map(MetadataField::name)\n\t\t\t\t\t.toList());\n\t\t\t}\n\t\t\tthrow new IllegalArgumentException(String.format(\"Field '%s' is not a TEXT field\", normalizedFieldName));\n\t\t}\n\t}\n\n\t/**\n\t * Normalizes a field name by removing @ prefix and JSON path prefix.\n\t * @param fieldName the field name to normalize\n\t * @return the normalized field name\n\t */\n\tprivate String normalizeFieldName(String fieldName) {\n\t\tString result = fieldName;\n\t\tif (result.startsWith(\"@\")) {\n\t\t\tresult = result.substring(1);\n\t\t}\n\t\tif (result.startsWith(JSON_PATH_PREFIX)) {\n\t\t\tresult = result.substring(JSON_PATH_PREFIX.length());\n\t\t}\n\t\treturn result;\n\t}","sourceCodeStart":771,"sourceCodeEnd":807,"githubUrl":"https://github.com/spring-projects/spring-ai/blob/98a7beda4f29d80a71c5837eb4053b03a93a46f7/vector-stores/spring-ai-redis-store/src/main/java/org/springframework/ai/vectorstore/redis/RedisVectorStore.java#L771-L807","documentation":"RedisVectorStore.validateTextField() (used by text-based search, e.g. searchByText) verifies that the requested field is declared with FieldType.TEXT in the index metadata. If the normalized field name is not a TEXT field, it throws this IllegalArgumentException after logging the available TEXT fields in debug mode. Searching with full-text match operators on TAG or NUMERIC fields is not allowed.","triggerScenarios":"Calling a text search API with a field name that is either not indexed at all, indexed as TAG or NUMERIC, or that normalizes (prefix/@path stripping) to a different name than the declared one.","commonSituations":"Using a tag field (exact-match) in a full-text search call; field name passed with '@' or JSON-path prefix that does not match after normalization; typo in the field name; store configured with metadataFields that omit TEXT declarations for the field.","solutions":["Declare the field with FieldType.TEXT in the store's metadataFields configuration","Pass the field name exactly as declared (without '@' or JSON path prefix)","Enable debug logging to see the available TEXT fields and pick a valid one","If the field should be tag-searchable, use the corresponding tag filter API instead of text search"],"exampleFix":"// before\nRedisVectorStore.builder().metadataFields(new MetadataField(\"description\", FieldType.TAG)) ... searchByText(\"description\", q)\n// after\nRedisVectorStore.builder().metadataFields(new MetadataField(\"description\", FieldType.TEXT)) ... searchByText(\"description\", q)","handlingStrategy":"validation","validationCode":"boolean isText = storeFields.stream().anyMatch(f -> f.name().equals(fieldName) && f.fieldType() == FieldType.TEXT);\nif (!isText) throw new IllegalArgumentException(fieldName + \" is not a TEXT field\");","typeGuard":"static boolean isTextField(MetadataField f) { return f != null && f.fieldType() == FieldType.TEXT; }","tryCatchPattern":"try { store.searchByText(field, query); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"is not a TEXT field\")) { /* use a declared TEXT field or tag-search API */ } }","preventionTips":["Declare searchable string fields as FieldType.TEXT","Strip '@' and JSON-path prefixes; pass bare declared names","Enable debug logging to list available TEXT fields during development"],"tags":["redis","vector-store","text-search","field-type"],"backgroundTag":"invalid-argument-value","analyzedSha":"98a7beda4f29d80a71c5837eb4053b03a93a46f7","analyzedAt":"2026-09-11T14:15:49.441Z","contentChangedAt":"2026-09-11T14:15:49.441Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}