org.apache.lucene.search.Query query = new TermQuery(productIdTerm);
Hits hits = searcher.search(query);
// should be exactly 1 hit
if (hits.length() != 1) {
throw new CatalogException("Product: ["
+ product.getProductId()
+ "] is not unique in the catalog! Num Hits: ["
+ hits.length() + "]");
}
Document productDoc = hits.doc(0);
CompleteProduct prod = toCompleteProduct(productDoc, false, true);
return prod.getMetadata();
} catch (IOException e) {
LOG.log(Level.WARNING,
"IOException when opening index directory: ["
+ indexFilePath + "] for search: Message: "
+ e.getMessage());
throw new CatalogException(e.getMessage());
} finally {
if (searcher != null) {
try {
searcher.close();
} catch (Exception ignore) {