FacetFields facetFields = new FacetFields(taxoWriter);
Document doc = new Document();
doc.add(newTextField("field", "text", Field.Store.NO));
BytesRef br = new BytesRef(new byte[] {(byte) 0xee, (byte) 0x92, (byte) 0xaa, (byte) 0xef, (byte) 0x9d, (byte) 0x89});
facetFields.addFields(doc, Collections.singletonList(new CategoryPath("dim/" + br.utf8ToString(), '/')));
try {
writer.addDocument(doc);
} catch (IllegalArgumentException iae) {
// expected
}