Ejemplo n.º 1
0
 // add items to index
 public void newIndex(NewIndexItem newIndexItem) throws IOException {
   // deleting the item, if already exists
   // indexWriter.deleteDocuments(new Term(IndexItem.SEARCHLABEL,
   // indexItem.getSearchLabel().toString()));
   Document doc = new Document();
   doc.add(
       new Field(
           NewIndexItem.QUERYNUMBER,
           newIndexItem.getNewQueryNumber().toString(),
           Field.Store.YES,
           Field.Index.ANALYZED));
   doc.add(
       new Field(
           NewIndexItem.TERMID,
           newIndexItem.getNewTermID().toString(),
           Field.Store.YES,
           Field.Index.ANALYZED));
   doc.add(
       new Field(
           NewIndexItem.LABEL,
           newIndexItem.getNewLabel().toString(),
           Field.Store.YES,
           Field.Index.ANALYZED));
   doc.add(
       new Field(
           NewIndexItem.SEARCHLABEL,
           newIndexItem.getNewSearchLabel().toString(),
           Field.Store.YES,
           Field.Index.ANALYZED));
   doc.add(
       new Field(
           NewIndexItem.QUERYTERM,
           newIndexItem.getNewQueryTerm().toString(),
           Field.Store.YES,
           Field.Index.ANALYZED));
   doc.add(
       new Field(
           NewIndexItem.NUMOFRESULTS,
           newIndexItem.getNewNumOfResults().toString(),
           Field.Store.YES,
           Field.Index.ANALYZED));
   // add the document to the index
   indexWriter2.addDocument(doc);
 }