lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wen Gao <samuel.gao...@gmail.com>
Subject Re: [Lucene.Net] how to add a new record to existing index
Date Wed, 02 Mar 2011 23:42:35 GMT
Hi Digy,
It was my fault that i didnt say it clearly. I mean I have created an
index,but it is not updated real time. So I want to update the index
everytime after I add data to database to keep the index up-to-date. My data
is what user inputs and inserted to database.Then

BTW, I know how to delete a term from index using IndexReader. Likewise, I
want to write a term to the created index instead of creating a new index.
I appreciate your time.

Thanks,
Wen

2011/3/2 Digy <digydigy@gmail.com>

>
> First of all, your code doesn't mean anything to me other than you add some
> fields to a document object.
>
> Also,  I can't see what you mean with *existing* index. The directory you
> pass to the IndexWriter is the index you use
> and every document added(using IndexWriter's AddDocument) is written to
> that
> index.
>
> I think, we have problems in using a common terminology.
>
> DIGY
>
> PS: It would be better if you use "user" mailing list to ask questions.
> This
> mailing lists is intented to be for development purposes.
>
>
>
>
> -----Original Message-----
> From: Wen Gao [mailto:samuel.gaowen@gmail.com]
> Sent: Wednesday, March 02, 2011 11:02 PM
> To: lucene-net-dev@lucene.apache.org
> Subject: [Lucene.Net] how to add a new record to existing index
>
> 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