@Override public void process(JCas aJCas) throws AnalysisEngineProcessException { DocumentMetaData meta = iterate(aJCas, DocumentMetaData.class).iterator().next(); // make a new, empty document Document doc = new Document(); // Add the document metadata. Use fields that are indexed (i.e. searchable), but don't // tokenize the field into words. doc.add(new Field("documentUri", meta.getDocumentUri(), Store.YES, Index.NOT_ANALYZED)); doc.add(new Field("documentBaseUri", meta.getDocumentBaseUri(), Store.YES, Index.NOT_ANALYZED)); doc.add(new Field("language", aJCas.getDocumentLanguage(), Store.YES, Index.NOT_ANALYZED)); // Add all tokens to the index without any further processing. doc.add(new Field("token", AnnotationStream.create(iterate(aJCas, Token.class)), TermVector.YES)); // Optionally store the document text. It can be retrieved but not searched. if (storeText) { doc.add(new Field("text", aJCas.getDocumentText(), Store.YES, Index.NO)); } try { writer.addDocument(doc); } catch (IOException e) { throw new AnalysisEngineProcessException(e); } }