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) {