lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wen Gao <samuel.gao...@gmail.com>
Subject [Lucene.Net] how to add a new record to existing index
Date Wed, 02 Mar 2011 21:01:37 GMT
Hi,
I already have created an index, and I want to insert an index record to
this existing index everytime I insert a new record to database.
For example,  if I want to insert an reord ("l1", "15","tom",
"20","2010/01/02") to my *existing* index, how can i do this? (I dont want
to create a new index, which takes too much time)

my format of index is as follows:
 ///////////////////////////
 doc.Add(new Lucene.Net.Documents.Field(
                "lmname",
                readerreader1["lmname"].ToString(),
                    //new
System.IO.StringReader(readerreader["cname"].ToString()),
                Lucene.Net.Documents.Field.Store.YES,
                 Lucene.Net.Documents.Field.Index.TOKENIZED)

                );

                //lmid
                doc.Add(new Lucene.Net.Documents.Field(
                "lmid",
                readerreader1["lmid"].ToString(),
                 Lucene.Net.Documents.Field.Store.YES,
                 Lucene.Net.Documents.Field.Index.UN_TOKENIZED));

                // nick name of user
                doc.Add(new Lucene.Net.Documents.Field(
                "nickName",
                 readerreader1["nickName"].ToString(),
                 Lucene.Net.Documents.Field.Store.YES,
                 Lucene.Net.Documents.Field.Index.UN_TOKENIZED));
                // uid
                doc.Add(new Lucene.Net.Documents.Field(
                "uid",
                 readerreader1["uid"].ToString(),
                 Lucene.Net.Documents.Field.Store.YES,
                 Lucene.Net.Documents.Field.Index.UN_TOKENIZED));

                // acttime
                doc.Add(new Lucene.Net.Documents.Field(
                "acttime",
                 readerreader1["acttime"].ToString(),
                 Lucene.Net.Documents.Field.Store.YES,
                 Lucene.Net.Documents.Field.Index.UN_TOKENIZED));
                writer.AddDocument(doc);
                ///////////////////////////////////////////////////

Thanks,
Wen

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message