diff --git a/hollow/src/main/java/com/netflix/hollow/tools/history/keyindex/HollowHistoryKeyIndex.java b/hollow/src/main/java/com/netflix/hollow/tools/history/keyindex/HollowHistoryKeyIndex.java index 1f163308ab..5cf315573e 100644 --- a/hollow/src/main/java/com/netflix/hollow/tools/history/keyindex/HollowHistoryKeyIndex.java +++ b/hollow/src/main/java/com/netflix/hollow/tools/history/keyindex/HollowHistoryKeyIndex.java @@ -64,7 +64,16 @@ public void addTypeIndex(PrimaryKey primaryKey) { } public HollowHistoryTypeKeyIndex addTypeIndex(PrimaryKey primaryKey, HollowDataset dataModel) { + HollowHistoryTypeKeyIndex prevKeyIdx = typeKeyIndexes.get(primaryKey.getType()); HollowHistoryTypeKeyIndex keyIdx = new HollowHistoryTypeKeyIndex(primaryKey, dataModel); + // retain any previous indexed fields + if (prevKeyIdx != null) { + for (int i = 0; i < prevKeyIdx.getKeyFields().length; i++) { + if (prevKeyIdx.getKeyFieldIsIndexed()[i]) { + keyIdx.addFieldIndex(prevKeyIdx.getKeyFields()[i], dataModel); + } + } + } typeKeyIndexes.put(primaryKey.getType(), keyIdx); return keyIdx; } diff --git a/hollow/src/main/java/com/netflix/hollow/tools/history/keyindex/HollowHistoryTypeKeyIndex.java b/hollow/src/main/java/com/netflix/hollow/tools/history/keyindex/HollowHistoryTypeKeyIndex.java index 314b65ff04..d6852bcb67 100644 --- a/hollow/src/main/java/com/netflix/hollow/tools/history/keyindex/HollowHistoryTypeKeyIndex.java +++ b/hollow/src/main/java/com/netflix/hollow/tools/history/keyindex/HollowHistoryTypeKeyIndex.java @@ -78,6 +78,10 @@ public String[] getKeyFields() { return primaryKey.getFieldPaths(); } + public boolean[] getKeyFieldIsIndexed() { + return keyFieldIsIndexed; + } + public void addFieldIndex(String fieldName, HollowDataset dataModel) { String[] fieldPathParts = PrimaryKey.getCompleteFieldPathParts(dataModel, primaryKey.getType(), fieldName); for (int i = 0; i < primaryKey.numFields(); i++) {