1 package com.knowgate.lucene; 2 3 import java.io.InputStream ; 4 import java.io.IOException ; 5 6 import java.util.Date ; 7 8 import java.math.BigDecimal ; 9 10 import org.apache.lucene.index.IndexWriter; 11 import org.apache.lucene.document.Document; 12 import com.knowgate.misc.Gadgets; 13 import org.apache.lucene.document.Field; 14 15 20 public class NewsMessageIndexer extends Indexer { 21 22 public NewsMessageIndexer() { 23 } 24 25 public static void addNewsMessage(IndexWriter oIWrt, 26 String sGuid, String sWorkArea, 27 String sContainer, String sTitle, 28 String sAuthor, Date dtCreated, 29 String sText) 30 throws ClassNotFoundException , IOException , IllegalArgumentException , 31 NoSuchFieldException , IllegalAccessException , InstantiationException , 32 NullPointerException { 33 34 Document oDoc = new Document(); 35 oDoc.add (Field.Keyword ("workarea" , sWorkArea)); 36 oDoc.add (Field.Keyword ("container", sContainer)); 37 oDoc.add (Field.Keyword ("guid" , sGuid)); 38 oDoc.add (Field.Text ("title" , Gadgets.ASCIIEncode(sTitle))); 39 oDoc.add (Field.Keyword ("created" , dtCreated)); 40 oDoc.add (Field.Text ("author" , Gadgets.ASCIIEncode(sAuthor))); 41 oDoc.add (Field.UnStored("text" , Gadgets.ASCIIEncode(sText))); 42 if (sText.length()>80) 43 oDoc.add (new Field("abstract", sText.substring(0,80), true, false, false)); 44 else 45 oDoc.add (new Field("abstract", sText, true, false, false)); 46 oIWrt.addDocument(oDoc); 47 } } 49 | Popular Tags |