@Override public Observable<IndexOperationMessage> deleteIndexEdge( final ApplicationScope applicationScope, final Edge edge ) { final Observable<IndexOperationMessage> batches = Observable.just( edge ).map( edgeValue -> { final EntityIndex ei = entityIndexFactory.createEntityIndex(indexLocationStrategyFactory.getIndexLocationStrategy(applicationScope) ); EntityIndexBatch batch = ei.createBatch(); //review why generating the Scope from the Source and the target node makes sense. final IndexEdge fromSource = generateScopeFromSource( edge ); final Id targetId = edge.getTargetNode(); CandidateResults targetEdgesToBeDeindexed = ei.getAllEdgeDocuments( fromSource, targetId ); //1. Feed the observable the candidate results you got back. Since it now does the aggregation for you // you don't need to worry about putting your code in a do while. batch = deindexBatchIteratorResolver( fromSource, targetEdgesToBeDeindexed, batch ); final IndexEdge fromTarget = generateScopeFromTarget( edge ); final Id sourceId = edge.getSourceNode(); CandidateResults sourceEdgesToBeDeindexed = ei.getAllEdgeDocuments( fromTarget, sourceId ); batch = deindexBatchIteratorResolver( fromTarget, sourceEdgesToBeDeindexed, batch ); return batch.build(); } ); return ObservableTimer.time( batches, addTimer ); }