}
Term idTerm = new Term(idAttribute, bean.getString(idAttribute));
Document docToUpdate = getUniqueDocument(indexReader, idTerm, crid);
// get the category paths for the facets
CategoryDocumentBuilder categoryDocBuilder = null;
if (useFacets && taxonomyAccessor != null && taxonomyWriter != null) {
List<CategoryPath> categories = getCategoryAttributeMapping(bean, taxonomyAccessor.getTaxonomyMappings());
if (categories.size() > 0) {
categoryDocBuilder = new CategoryDocumentBuilder(taxonomyWriter).setCategoryPaths(categories);
}
}
if (!create && docToUpdate != null) {
Document doc = getDocument(docToUpdate, bean, attributes, config, reverseattributes);
// add facets to document
if (categoryDocBuilder != null) {
categoryDocBuilder.build(doc);
}
indexWriter.updateDocument(idTerm, doc);
} else {
Document doc = getDocument(null, bean, attributes, config, reverseattributes);
// add facets to document
if (categoryDocBuilder != null) {
categoryDocBuilder.build(doc);
}
indexWriter.addDocument(doc);
}
} finally {
bcase.stop();