private void indexDocument(IndexWriter iw, NewsStory newsStory) throws IOException { org.apache.lucene.document.Document doc = new org.apache.lucene.document.Document(); FieldType customType = new FieldType(TextField.TYPE_NOT_STORED); customType.setStoreTermVectors(true); customType.setStoreTermVectorPositions(true); customType.setStoreTermVectorOffsets(false); doc.add(new Field(INDEX_FIELD_CONTENT, newsStory.getContent().getText(), customType)); doc.add(new StringField(INDEX_FIELD_URL, newsStory.getUrl(), Field.Store.YES)); doc.add(new StringField(INDEX_FIELD_DOC_ID, newsStory.getId(), Field.Store.YES)); doc.add(new TextField(INDEX_FIELD_TITLE, newsStory.getTitle(), Field.Store.YES)); iw.addDocument(doc); }
private void addStory(NewsStory newsStory) { allStoriesMap.put(newsStory.getId(), newsStory); }