lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erick Erickson" <erickerick...@gmail.com>
Subject Re: Adding Documents to index in a batch process
Date Sun, 01 Jul 2007 21:42:12 GMT
It's almost entirely trivial. Note that the IndexHandler is the name of my
singleton class....

Here's the meat of the class....

   private static IndexSearcher indexSearcher;

    public static synchronized IndexSearcher getSearcher()
        throws Exception
    {
        if (IndexHandler.indexSearcher == null) {
            IndexHandler.indexSearcher = new IndexSearcher(index);
        }

        return IndexHandler.indexSearcher;
    }


and you call it by
IndexHandler.getSearcher().......

Erick

On 6/28/07, Kai Weber <kai.weber@glorybox.de> wrote:
>
> * Erick Erickson <erickerickson@gmail.com>:
> > I guess I don't understand the problem. Can you build the documents
> > from within a loop or not? If you can, it's simple...
> >
> > open indexwriter
> > while (build a document)
> >    write to index
> >
> > close/optimize.
> >
> > Or are you saying that you can't build from within a loop?
>
> Thats true, no loop.
>
> I think I have to save the IndexWriter instance somewhere in application
> scope or wrap it as a singleton.
>
> Is there any example code I could reuse or learn from?
>
> Kai
> --
> * http://www.glorybox.de/
>   PGP 1024D/594D4132 B693 5073 013F 7F56 5DCC  D9C2 E6B5 448C 594D 4132
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

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