If I recall correctly, waitSearcher only affects the opening of the new 
Searcher, and not the part of the optimize where the segments are being merged 
together (the long part). I took a quick look at DirectUpdateHandler2, and I 
don't see anything to allow the request to return immediately. I think you'll 
need to run it on a separate thread.

-Michael

-----Original Message-----
From: Shawn Heisey [mailto:apa...@elyograg.org] 
Sent: Friday, May 01, 2015 10:09 AM
To: solr-user@lucene.apache.org
Subject: Re: How to start an optimize in SolrJ without waiting for it to 
complete?

On 5/1/2015 7:23 AM, Shawn Heisey wrote:
> This is my solrj code:
> 
>   UpdateRequest req = new UpdateRequest("/" + _name + "/update");
>   req.setAction(UpdateRequest.ACTION.OPTIMIZE, false, false);
>   UpdateResponse ur = req.process(_client);

Followup.  I must not have actually been running that code, because when I 
created a test program and ran it, I got this in the log:

INFO  - 2015-05-01 08:04:02.246;
org.apache.solr.update.processor.LogUpdateProcessor; [s5live] webapp=/solr 
path=/update 
params={optimize=true&waitSearcher=false&maxSegments=1&wt=javabin&version=2}
{optimize=} 0 1221053

Now waitSearcher is set to false, but the call in SolrJ still took over
20 minutes, when what I was after was an immediate return.

Will I need to start a separate thread to allow my program to continue running 
while an optimize is happening?

Thanks,
Shawn

Reply via email to