// obtain the sample facets for current document
List<CategoryPath> facetList = SimpleUtils.categoryPathArrayToList(SimpleUtils.categories[docNum]);
// we do not alter indexing parameters!
// a category document builder will add the categories to a document once build() is called
DocumentBuilder categoryDocBuilder = new CategoryDocumentBuilder(taxo).setCategoryPaths(facetList);
// create a plain Lucene document and add some regular Lucene fields to it
Document doc = new Document();
doc.add(new Field(SimpleUtils.TITLE, SimpleUtils.docTitles[docNum], Store.YES, Index.ANALYZED));
doc.add(new Field(SimpleUtils.TEXT, SimpleUtils.docTexts[docNum], Store.NO, Index.ANALYZED));
// invoke the category document builder for adding categories to the document and,
// as required, to the taxonomy index
categoryDocBuilder.build(doc);
// finally add the document to the index
iw.addDocument(doc);
nDocsAdded ++;