UseCase ucReIndex = MonitorFactory.startUseCase("reIndex()");
// build a dictionary (from the spell package)
log.debug("Starting to reindex didyoumean index.");
IndexAccessor sourceAccessor = didyoumean.getSourceLocation().getAccessor();
IndexReader sourceReader = sourceAccessor.getReader(false);
CustomSpellChecker spellchecker = didyoumean.getSpellchecker();
Collection<String> fields = null;
if (didyoumean.isAll()) {
fields = sourceReader.getFieldNames(IndexReader.FieldOption.ALL);
} else {
fields = didyoumean.getDym_fields();
}
try {
for (String fieldname : fields) {
LuceneDictionary dict = new LuceneDictionary(sourceReader, fieldname);
spellchecker.indexDictionary(dict);
}
} finally {
if (sourceAccessor != null && sourceReader != null) {
sourceAccessor.release(sourceReader, false);
}