Esempio n. 1
0
        public static void parse_msg(Lucene.Net.Index.IndexWriter writer, string docid, string msgtxt)
        {
            if (msgtxt.Length > 4 * 1024) {
                msgtxt = msgtxt.Substring(0, 4 * 1024 - 1);
            }
            // db.setValueParsed(".zdata/doc/" + docid, msgtxt);
            // gui.debugDump(db);

            if (true) {
                // sharptools
                SharpMessage msg = new anmar.SharpMimeTools.SharpMessage(msgtxt);
                System.Console.WriteLine("Subject: " + msg.Subject);
                var doc = new Lucene.Net.Documents.Document();
                doc.Add(new Field("body", msg.Body, Field.Store.YES, Field.Index.ANALYZED));
                doc.Add(new Field("docid", docid, Field.Store.YES, Field.Index.NOT_ANALYZED));
                writer.AddDocument(doc);
                // indexer.index_document(docid, msg.Body);
            }

            //foreach (SharpAttachment msgpart in msg.Attachments) {
            //    if (msgpart.MimeTopLevelMediaType == MimeTopLevelMediaType.text &&
            //        msgpart.MimeMediaSubType == "plain") {
            //        System.Console.WriteLine("Attachment: " + msgpart.Size);
            //   }
            //}
        }
		private static void  AddDateDoc(System.String content, int year, int month, int day, int hour, int minute, int second, Lucene.Net.Index.IndexWriter iw)
		{
			Lucene.Net.Documents.Document d = new Lucene.Net.Documents.Document();
			d.Add(new Lucene.Net.Documents.Field("f", content, Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.TOKENIZED));
			System.DateTime tempAux = new System.DateTime(year, month, day, hour, minute, second);
			d.Add(new Lucene.Net.Documents.Field("date", DateField.DateToString(tempAux), Lucene.Net.Documents.Field.Store.YES, Lucene.Net.Documents.Field.Index.UN_TOKENIZED));
			iw.AddDocument(d);
		}