Is there any way to optimize existing unoptimized index?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Is there any way to optimize existing unoptimized index?

maureen tanuwidjaja
Hi,
 
  May I also ask wheter there is a way to use writer.optimize() without indexing the files from the beginning?
 
  It took me about 17 hrs to finish building an unoptimized index(finish  when I call IndexWriter.close() ).I just wonder wheter this existing  index could be optimized...
 
  THanks and Best Regards,
  Maureen
 
 
---------------------------------
Everyone is raving about the all-new Yahoo! Mail beta.
Reply | Threaded
Open this post in threaded view
|

Re: Is there any way to optimize existing unoptimized index?

Patrek
Hi,

From my own experience, yes, you can.

You just have to reopen your index with a new IndexWriter (making sure you
don't use a constructor that will recreate it; from the javadoc, stay clear
of those with a boolean argument). Then call optimize() then close() on your
writer, it will be optimized for you.

I think you can also use Luke (google Luke Lucene) to do this.

In any cases, I suggest you backup your index before trying, just to be
sure.

Hope this helps.

Patrick

On 2/7/07, maureen tanuwidjaja <[hidden email]> wrote:

>
> Hi,
>
>   May I also ask wheter there is a way to use writer.optimize() without
> indexing the files from the beginning?
>
>   It took me about 17 hrs to finish building an unoptimized
> index(finish  when I call IndexWriter.close() ).I just wonder wheter this
> existing  index could be optimized...
>
>   THanks and Best Regards,
>   Maureen
>
>
> ---------------------------------
> Everyone is raving about the all-new Yahoo! Mail beta.
Reply | Threaded
Open this post in threaded view
|

Re: Is there any way to optimize existing unoptimized index?

Michael McCandless-2
In reply to this post by maureen tanuwidjaja
maureen tanuwidjaja wrote:

>   May I also ask wheter there is a way to use writer.optimize() without indexing the files from the beginning?
>  
>   It took me about 17 hrs to finish building an unoptimized index(finish  when I call IndexWriter.close() ).I just wonder wheter this existing  index could be optimized...

You can always open a new IndexWriter on your index, do things like
addDocument, optimize, etc., and then close it.

There's no requirement that you do addDocument / optimize in a single
session of IndexWriter.

But do be careful not to pass "create = true" to IndexWriter.

The trunk (soon to be 2.1 release) version of Lucene has new
IndexWriter constructors that "create when needed, else append", see
here:

     http://issues.apache.org/jira/browse/LUCENE-301

Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]