You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Shawn Heisey <so...@elyograg.org> on 2012/10/11 22:02:00 UTC
SolrJ, optimize, maxSegments
Currently my indexing code calls optimize. Once a night, one of my six
large shards is optimized, so each one only gets optimized once every
six days. Here is the SolrJ call, server is an instance of HttpSolrServer:
UpdateResponse ur = server.optimize();
I only do this because I want deleted documents regularly removed from
the index. Whatever speed gains I might see from getting down to one
segment are just an added bonus. After watching all the discussion on
the -dev list regarding what to do in Solr due to the Lucene forceMerge
rename, I am considering changing this to something like the following:
UpdateResponse ur = server.optimize(true, true, 20);
What happens with this if I am already below 20 segments? Will it still
expunge all of my (typically several thousand) deleted documents? I am
hoping that what it will do is rebuild any segment that contains deleted
documents and leave the other segments alone. Possibly irrelevant info:
I'm using the following MP config:
<mergePolicy class="org.apache.lucene.index.TieredMergePolicy">
<int name="maxMergeAtOnce">35</int>
<int name="segmentsPerTier">35</int>
<int name="maxMergeAtOnceExplicit">105</int>
</mergePolicy>
Thanks,
Shawn
Re: SolrJ, optimize, maxSegments
Posted by Gopal Patwa <go...@gmail.com>.
Did you tried below options
<mergePolicy class="org.apache.lucene.index.TieredMergePolicy">
<double name="forceMergeDeletesPctAllowed">0.0</double>
<double name="reclaimDeletesWeight">10.0</double>
</mergePolicy>
This is from java doc
/** When forceMergeDeletes is called, we only merge away a
* segment if its delete percentage is over this
* threshold. Default is 10%. */
public TieredMergePolicy setForceMergeDeletesPctAllowed(double v) {
if (v < 0.0 || v > 100.0) {
throw new IllegalArgumentException("forceMergeDeletesPctAllowed must
be between 0.0 and 100.0 inclusive (got " + v + ")");
}
forceMergeDeletesPctAllowed = v;
return this;
}
On Fri, Oct 12, 2012 at 3:16 PM, Erick Erickson <er...@gmail.com>wrote:
> Sounds reasonable although I admit I haven't looked deeply.....
>
> Erick
>
> On Fri, Oct 12, 2012 at 3:41 PM, Shawn Heisey <so...@elyograg.org> wrote:
> > On 10/12/2012 6:04 AM, Erick Erickson wrote:
> >>
> >> Hmmm, I dug around in the code and found this bit:
> >> * Forces merging of all segments that have deleted
> >> * documents. The actual merges to be executed are
> >> * determined by the {@link MergePolicy}. For example,
> >> * the default {@link TieredMergePolicy} will only
> >> * pick a segment if the percentage of
> >> * deleted docs is over 10%.
> >>
> >> see IndexWriter.forceMergeDeletes. So perhaps this limit
> >> was never hit?
> >
> >
> > My own digging based on yours turned up this:
> >
> > https://issues.apache.org/jira/browse/SOLR-2725
> >
> > This sounds like there is currently no way to change this in the Solr
> > config, so it looks like my choices right now are to make a source code
> > change and respin the Solr 3.5.0 that I'm using or just continue to use
> > optimize with no options until SOLR-2725 gets resolved and I can upgrade.
> > Is that right?
> >
> > Thanks,
> > Shawn
> >
>
Re: SolrJ, optimize, maxSegments
Posted by Erick Erickson <er...@gmail.com>.
Sounds reasonable although I admit I haven't looked deeply.....
Erick
On Fri, Oct 12, 2012 at 3:41 PM, Shawn Heisey <so...@elyograg.org> wrote:
> On 10/12/2012 6:04 AM, Erick Erickson wrote:
>>
>> Hmmm, I dug around in the code and found this bit:
>> * Forces merging of all segments that have deleted
>> * documents. The actual merges to be executed are
>> * determined by the {@link MergePolicy}. For example,
>> * the default {@link TieredMergePolicy} will only
>> * pick a segment if the percentage of
>> * deleted docs is over 10%.
>>
>> see IndexWriter.forceMergeDeletes. So perhaps this limit
>> was never hit?
>
>
> My own digging based on yours turned up this:
>
> https://issues.apache.org/jira/browse/SOLR-2725
>
> This sounds like there is currently no way to change this in the Solr
> config, so it looks like my choices right now are to make a source code
> change and respin the Solr 3.5.0 that I'm using or just continue to use
> optimize with no options until SOLR-2725 gets resolved and I can upgrade.
> Is that right?
>
> Thanks,
> Shawn
>
Re: SolrJ, optimize, maxSegments
Posted by Shawn Heisey <so...@elyograg.org>.
On 10/12/2012 6:04 AM, Erick Erickson wrote:
> Hmmm, I dug around in the code and found this bit:
> * Forces merging of all segments that have deleted
> * documents. The actual merges to be executed are
> * determined by the {@link MergePolicy}. For example,
> * the default {@link TieredMergePolicy} will only
> * pick a segment if the percentage of
> * deleted docs is over 10%.
>
> see IndexWriter.forceMergeDeletes. So perhaps this limit
> was never hit?
My own digging based on yours turned up this:
https://issues.apache.org/jira/browse/SOLR-2725
This sounds like there is currently no way to change this in the Solr
config, so it looks like my choices right now are to make a source code
change and respin the Solr 3.5.0 that I'm using or just continue to use
optimize with no options until SOLR-2725 gets resolved and I can
upgrade. Is that right?
Thanks,
Shawn
Re: SolrJ, optimize, maxSegments
Posted by Erick Erickson <er...@gmail.com>.
Hmmm, I dug around in the code and found this bit:
* Forces merging of all segments that have deleted
* documents. The actual merges to be executed are
* determined by the {@link MergePolicy}. For example,
* the default {@link TieredMergePolicy} will only
* pick a segment if the percentage of
* deleted docs is over 10%.
see IndexWriter.forceMergeDeletes. So perhaps this limit
was never hit?
Best
Erick
On Thu, Oct 11, 2012 at 6:10 PM, Shawn Heisey <so...@elyograg.org> wrote:
> On 10/11/2012 2:02 PM, Shawn Heisey wrote:
>>
>> UpdateResponse ur = server.optimize(true, true, 20);
>>
>> What happens with this if I am already below 20 segments? Will it still
>> expunge all of my (typically several thousand) deleted documents? I am
>> hoping that what it will do is rebuild any segment that contains deleted
>> documents and leave the other segments alone.
>
>
> I have just tried this on a test system with 11 segments via curl, not
> SolrJ. I don't expect that it would be any different with SolrJ, though.
>
> curl
> 'http://localhost:8981/solr/s0live/update?optimize=true&maxSegments=20&expungeDeletes=true&waitFlush=true'
>
> It didn't work. When I changed maxSegments to 10, it did reduce the index
> from 11 segments to 10, but there are still deleted documents in the index
> -- maxDoc > numDocs on the statistics screen.
>
> numDocs : 12782762
> maxDoc : 12788156
>
> I don't think expungeDeletes is actually a valid parameter for optimize, but
> I included it anyway. I also tried doing a commit with expungeDeletes=true
> and that didn't work either.
>
> Is this a bug? The server is 3.5.0. Because I haven't finished getting my
> configuration worked out, I don't have the ability right now to try this on
> 4.0.0.
>
> Thanks,
> Shawn
>
Re: SolrJ, optimize, maxSegments
Posted by Shawn Heisey <so...@elyograg.org>.
On 10/11/2012 2:02 PM, Shawn Heisey wrote:
> UpdateResponse ur = server.optimize(true, true, 20);
>
> What happens with this if I am already below 20 segments? Will it
> still expunge all of my (typically several thousand) deleted
> documents? I am hoping that what it will do is rebuild any segment
> that contains deleted documents and leave the other segments alone.
I have just tried this on a test system with 11 segments via curl, not
SolrJ. I don't expect that it would be any different with SolrJ, though.
curl
'http://localhost:8981/solr/s0live/update?optimize=true&maxSegments=20&expungeDeletes=true&waitFlush=true'
It didn't work. When I changed maxSegments to 10, it did reduce the
index from 11 segments to 10, but there are still deleted documents in
the index -- maxDoc > numDocs on the statistics screen.
numDocs : 12782762
maxDoc : 12788156
I don't think expungeDeletes is actually a valid parameter for optimize,
but I included it anyway. I also tried doing a commit with
expungeDeletes=true and that didn't work either.
Is this a bug? The server is 3.5.0. Because I haven't finished getting
my configuration worked out, I don't have the ability right now to try
this on 4.0.0.
Thanks,
Shawn