Refcator common logic between IndexUpdate and DocumentStoreIndexer
@@ -38,6 +38,7 @@ import org.apache.jackrabbit.oak.plugins.document.DocumentNodeState;
import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStore;
import org.apache.jackrabbit.oak.plugins.document.mongo.MongoDocumentStore;
import org.apache.jackrabbit.oak.plugins.document.util.MongoConnection;
+import org.apache.jackrabbit.oak.plugins.index.IndexConstants;
import org.apache.jackrabbit.oak.plugins.index.IndexUpdateCallback;
import org.apache.jackrabbit.oak.plugins.index.NodeTraversalCallback;
import org.apache.jackrabbit.oak.plugins.index.progress.IndexingProgressReporter;
@@ -180,6 +181,11 @@ public class DocumentStoreIndexer implements Closeable{
log.warn("No 'type' property found on indexPath [{}]. Skipping it", indexPath);
continue;
}
+
+ removeIndexState(idxBuilder);
+
+ idxBuilder.setProperty(IndexConstants.REINDEX_PROPERTY_NAME, false);
+
for (NodeStateIndexerProvider indexerProvider : indexerProviders) {
NodeStateIndexer indexer = indexerProvider.getIndexer(type, indexPath, idxBuilder, root, progressReporter);
if (indexer != null) {
@@ -206,4 +212,18 @@ public class DocumentStoreIndexer implements Closeable{
private NodeStateIndexerProvider createLuceneIndexProvider() throws IOException {
return new LuceneIndexerProvider(indexHelper, indexerSupport);
}
+
+ //TODO OAK-7098 - Taken from IndexUpdate. Refactor to abstract out common logic like this
+ private void removeIndexState(NodeBuilder definition) {
+ // as we don't know the index content node name
+ // beforehand, we'll remove all child nodes
+ for (String rm : definition.getChildNodeNames()) {
+ if (NodeStateUtils.isHidden(rm)) {
+ NodeBuilder childNode = definition.getChildNode(rm);
+ if (!childNode.getBoolean(IndexConstants.REINDEX_RETAIN)) {
+ definition.getChildNode(rm).remove();
+ }
+ }
+ }
+ }
}
