ZoieSystem<IndexReader,DocumentWithID> zoie = zoieHome.getZoieSystem();
if (zoie==null){
throw new IOException("zoie is not setup");
}
final LongList delList = new LongArrayList();
List<ZoieIndexReader<IndexReader>> readerList = null;
IndexSearcher searcher = null;
try{
readerList = zoie.getIndexReaders();
MultiReader reader = new MultiReader(readerList.toArray(new IndexReader[readerList.size()]), false);
searcher = new IndexSearcher(reader);
searcher.search(q, new Collector(){
ZoieIndexReader<IndexReader> zoieReader = null;
int base = 0;
@Override
public boolean acceptsDocsOutOfOrder() {
return true;
}
@Override
public void collect(int doc) throws IOException {
long uid = zoieReader.getUID(doc+base);
if (uid!=DocIDMapper.NOT_FOUND){
delList.add(uid);
}
}
@Override
public void setNextReader(IndexReader reader, int base)
throws IOException {
zoieReader = (ZoieIndexReader<IndexReader>)reader;
this.base = base;
}
@Override
public void setScorer(Scorer scorer) throws IOException {
}
});
}
finally{
try{
if (searcher!=null){
searcher.close();
}
}
finally{
if (readerList!=null){
zoie.returnIndexReaders(readerList);
}
}
}
if (delList.size()>0){
long version = zoie.getCurrentVersion();
ArrayList<DataEvent<DocumentWithID>> eventList = new ArrayList<DataEvent<DocumentWithID>>(delList.size());
for (long val : delList){
eventList.add(new DataEvent<DocumentWithID>(version,new DocumentWithID(val,true)));
}
try {
zoie.consume(eventList);