lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anshum <ansh...@gmail.com>
Subject Re: Unable to add more than 1 document to Index
Date Thu, 24 Apr 2008 04:00:47 GMT
Hi Hasan,

The issue seems to be with the initialization of the index writer, try
initializing it with a the last parameter as false i.e.
*writer = new IndexWriter(indexLocation, new StandardAnalyzer(), false);
*If you initialize it with the last argument as true, it creates a new
index  each time @ the index location.
With the last argument as 'false' you would be able to append data to the
existing index.

Hope that solves the issue.

--
Anshum


On Thu, Apr 24, 2008 at 8:13 AM, Hasan Diwan <hasan.diwan@gmail.com> wrote:

>                writer = new IndexWriter(indexLocation, new
> StandardAnalyzer(), true);
>                String string = request.getParameter("text");
>                this.log("Text is "+string);
>                Date date = new Date();
>                String dateString = DateTools.dateToString(date,
> DateTools.Resolution.MINUTE);
>                this.log("Date is "+dateString);
>                Field allField = new Field("all", string, Field.Store.YES,
>  Field.Index.TOKENIZED);
>                Field dateField = new Field("date", dateString,
> Field.Store.YES,
>  Field.Index.UN_TOKENIZED);
>                doc.add(allField);
>                doc.add(dateField);
>                writer.addDocument(doc);
>                writer.optimize();
>                writer.close();
>
>  This code is supposed to get information from a JSP (and does) and put
>  it into a lucene index (and does) in a new document (and does not).
>  This is apparent when I query it using luke and the default lucene web
>  application. Any suggestions or pointers to what to do about this
>  would be eternally helpful? Thanks in advance!
> --
> Cheers,
> Hasan Diwan <hasan.diwan@gmail.com>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
--
The facts expressed here belong to everybody, the opinions to me.
The distinction is yours to draw............

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