Skip to content

Commit

Permalink
Merge pull request #102 from steleal/gh-101-fix_is_array_index
Browse files Browse the repository at this point in the history
GH-101 Fix is_array on index of single object field

Closes gh-101
  • Loading branch information
steleal authored Aug 15, 2024
2 parents 443e664 + 0393d07 commit 0dbcd70
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,14 @@ List<ReindexerIndex> 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<ReindexerIndex> nested = parseIndexes(field.getType(), true, reindexPath, jsonPath, joined);
List<ReindexerIndex> nested = parseIndexes(field.getType(), subArray, reindexPath, jsonPath, joined);
indexes.addAll(nested);
} else if ((fieldInfo.isArray) && fieldInfo.componentType != null
&& getFieldTypeByClass(fieldInfo.componentType) == COMPOSITE) {
Expand Down

0 comments on commit 0dbcd70

Please sign in to comment.