public List<NewsStory> findStoriesByTitle(String title) {
   List<NewsStory> results = new ArrayList<NewsStory>();
   if (title != null) {
     for (NewsStory s : allStoriesMap.values()) {
       if (title.equalsIgnoreCase(s.getTitle())) {
         results.add(s);
       }
     }
   }
   return results;
 }
예제 #2
0
  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);
  }