// check if semantic label already exists
Document labelDoc = null; // document corresponding to existing semantic label if exists
if (indexDirectoryExists()) {
try {
// check if semantic label already exists in index
Searcher searcher = new Searcher(indexDirectory,
Indexer.LABEL_FIELD_NAME);
try {
labelDoc = searcher.getDocumentForLabel(label);
} finally {
searcher.close();
}
} catch (Exception e) {
// Ignore, the searcher might not work if index is empty.
}
}