|
6 | 6 | import com.redis.om.spring.ops.RedisModulesOperations;
|
7 | 7 | import com.redis.om.spring.ops.search.SearchOperations;
|
8 | 8 | import com.redis.om.spring.repository.query.QueryUtils;
|
9 |
| -import com.redis.om.spring.serialization.gson.EnumTypeAdapter; |
| 9 | +import com.redis.om.spring.serialization.gson.*; |
10 | 10 | import org.apache.commons.lang3.ObjectUtils;
|
11 | 11 | import org.apache.commons.logging.Log;
|
12 | 12 | import org.apache.commons.logging.LogFactory;
|
@@ -213,10 +213,19 @@ private List<Field> findIndexFields(java.lang.reflect.Field field, String prefix
|
213 | 213 | //
|
214 | 214 | // Any Character class, Boolean or Enum with AUTODETECT -> Tag Search Field
|
215 | 215 | //
|
216 |
| - if (CharSequence.class.isAssignableFrom(fieldType) || (fieldType == Boolean.class) || |
217 |
| - (fieldType.isEnum())) { |
| 216 | + if (CharSequence.class.isAssignableFrom(fieldType) || (fieldType == Boolean.class)) { |
218 | 217 | fields.add(indexAsTagFieldFor(field, isDocument, prefix, indexed.sortable(), indexed.separator(),
|
219 | 218 | indexed.arrayIndex(), indexed.alias()));
|
| 219 | + } else if (fieldType.isEnum()) { |
| 220 | + switch (indexed.serializationHint()) { |
| 221 | + case ORDINAL -> { |
| 222 | + fields.add(indexAsNumericFieldFor(field, isDocument, prefix, indexed.sortable(), indexed.noindex(), |
| 223 | + indexed.alias())); |
| 224 | + gsonBuilder.registerTypeAdapter(fieldType, EnumTypeAdapter.of(fieldType)); |
| 225 | + } |
| 226 | + default -> fields.add(indexAsTagFieldFor(field, isDocument, prefix, indexed.sortable(), indexed.separator(), |
| 227 | + indexed.arrayIndex(), indexed.alias())); |
| 228 | + } |
220 | 229 | }
|
221 | 230 | //
|
222 | 231 | // Any Numeric class -> Numeric Search Field
|
@@ -293,11 +302,6 @@ else if (fieldType == Point.class) {
|
293 | 302 | fields.addAll(findIndexFields(subfield, subfieldPrefix, isDocument));
|
294 | 303 | }
|
295 | 304 | }
|
296 |
| - case ORDINAL -> { |
297 |
| - fields.add(indexAsNumericFieldFor(field, isDocument, prefix, indexed.sortable(), |
298 |
| - indexed.noindex(), indexed.alias())); |
299 |
| - gsonBuilder.registerTypeAdapter(fieldType, EnumTypeAdapter.of(fieldType)); |
300 |
| - } |
301 | 305 | }
|
302 | 306 | }
|
303 | 307 | }
|
|
0 commit comments