01: package com.knowgate.lucene;
02:
03: import java.io.InputStream;
04: import java.io.IOException;
05:
06: import java.util.Date;
07:
08: import java.math.BigDecimal;
09:
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: /**
16: * Indexer subclass for hipergate forum messages
17: * @author Sergio Montoro Ten
18: * @version 3.0
19: */
20: public class NewsMessageIndexer extends Indexer {
21:
22: public NewsMessageIndexer() {
23: }
24:
25: public static void addNewsMessage(IndexWriter oIWrt, String sGuid,
26: String sWorkArea, String sContainer, String sTitle,
27: String sAuthor, Date dtCreated, String sText)
28: throws ClassNotFoundException, IOException,
29: IllegalArgumentException, NoSuchFieldException,
30: IllegalAccessException, InstantiationException,
31: NullPointerException {
32:
33: Document oDoc = new Document();
34: oDoc.add(Field.Keyword("workarea", sWorkArea));
35: oDoc.add(Field.Keyword("container", sContainer));
36: oDoc.add(Field.Keyword("guid", sGuid));
37: oDoc.add(Field.Text("title", Gadgets.ASCIIEncode(sTitle)));
38: oDoc.add(Field.Keyword("created", dtCreated));
39: oDoc.add(Field.Text("author", Gadgets.ASCIIEncode(sAuthor)));
40: oDoc.add(Field.UnStored("text", Gadgets.ASCIIEncode(sText)));
41: if (sText.length() > 80)
42: oDoc.add(new Field("abstract", sText.substring(0, 80),
43: true, false, false));
44: else
45: oDoc.add(new Field("abstract", sText, true, false, false));
46: oIWrt.addDocument(oDoc);
47: } // addNewsMessage
48: }
|