From 0393d07f314a4d731f8d0c91dacd1d1f4bb37ffa Mon Sep 17 00:00:00 2001 From: Alexey Shtele Date: Thu, 15 Aug 2024 10:11:51 +0300 Subject: [PATCH] GH-101 Fix is_array on index of single object field --- .../reindexer/annotations/ReindexAnnotationScanner.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/ru/rt/restream/reindexer/annotations/ReindexAnnotationScanner.java b/src/main/java/ru/rt/restream/reindexer/annotations/ReindexAnnotationScanner.java index 35d07b9..4523dc7 100644 --- a/src/main/java/ru/rt/restream/reindexer/annotations/ReindexAnnotationScanner.java +++ b/src/main/java/ru/rt/restream/reindexer/annotations/ReindexAnnotationScanner.java @@ -129,11 +129,14 @@ List parseIndexes(Class itemClass, boolean subArray, String r Json json = field.getAnnotation(Json.class); String jsonPath = jsonBasePath + (json == null ? field.getName() : json.value()); FieldInfo fieldInfo = getFieldInfo(field); + + // If at least one array (collection) is encountered on a nested path for some field, + // or the field itself is an array, then the index on it must also be an array. if (subArray) { fieldInfo.isArray = true; } if (COMPOSITE == fieldInfo.fieldType && !fieldInfo.isArray) { - List nested = parseIndexes(field.getType(), true, reindexPath, jsonPath, joined); + List nested = parseIndexes(field.getType(), subArray, reindexPath, jsonPath, joined); indexes.addAll(nested); } else if ((fieldInfo.isArray) && fieldInfo.componentType != null && getFieldTypeByClass(fieldInfo.componentType) == COMPOSITE) {