Skip to content

Instantly share code, notes, and snippets.

@GERey
Created May 5, 2015 21:36
Show Gist options
  • Save GERey/a1726e876fed1bdc1167 to your computer and use it in GitHub Desktop.
Save GERey/a1726e876fed1bdc1167 to your computer and use it in GitHub Desktop.
deleteIndexEdge
final Observable<IndexOperationMessage> batches = Observable.just( edge ).map(
observableEdge -> generateScopeFromSource( edge ) ).flatMap( indexEdge -> {
final ApplicationEntityIndex ei = entityIndexFactory.createApplicationEntityIndex( applicationScope );
//TODO: make method to keep looping through elasticsearch until there are no more indexs to batchup
CandidateResults crs = ei.search( indexEdge, SearchTypes.fromTypes( edge.getType() ), "select *", 10, 0 );
final EntityIndexBatch batch = ei.createBatch();
logger.debug( "deleting edge {} to batch for scope {}", indexEdge, applicationScope );
//TODO: extract this into its own function.
Iterator itr = crs.iterator();
while( itr.hasNext() ) {
CandidateResult cr = ( CandidateResult ) itr.next();
batch.deindex( indexEdge, cr.getId(), cr.getVersion() );
}
return batch.execute();
} );
return ObservableTimer.time( batches, addTimer );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment