SOLR-755: facet.limit=-1 does not work in distributed search

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@692549 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2008-09-05 21:01:19 +00:00
parent 4a73efa0cd
commit daa32711c9
2 changed files with 20 additions and 9 deletions

View File

@ -359,7 +359,7 @@ public class FacetComponent extends SearchComponent
counts = dff.getSorted();
}
int end = Math.min(dff.offset + dff.limit, counts.length);
int end = dff.limit < 0 ? counts.length : Math.min(dff.offset + dff.limit, counts.length);
for (int i=dff.offset; i<end; i++) {
if (counts[i].count < dff.minCount) break;
fieldCounts.add(counts[i].name, num(counts[i].count));
@ -540,7 +540,7 @@ class DistribFieldFacet extends FieldFacet {
// the largest possible missing term is 0 if we received less
// than the number requested (provided mincount==0 like it should be for
// a shard request)
if (numRequested !=0 && numReceived < numRequested) {
if (numRequested<0 || numRequested != 0 && numReceived < numRequested) {
last = 0;
}

View File

@ -249,7 +249,7 @@ public class TestDistributedSearch extends TestCase {
boolean ordered = (flags&UNORDERED) == 0;
int posa = 0, posb = 0;
int na = 0, nb = 0;
int aSkipped = 0, bSkipped = 0;
for(;;) {
if (posa >= a.size() || posb >= b.size()) {
@ -265,8 +265,10 @@ public class TestDistributedSearch extends TestCase {
vala = a.getVal(posa);
posa++;
flagsa = flags(handle, namea);
if ((flagsa & SKIP) != 0) continue;
na++;
if ((flagsa & SKIP) != 0) {
aSkipped++;
continue;
}
break;
}
@ -277,9 +279,11 @@ public class TestDistributedSearch extends TestCase {
valb = b.getVal(posb);
posb++;
flagsb = flags(handle, nameb);
if ((flagsb & SKIP) != 0) continue;
if ((flagsb & SKIP) != 0) {
bSkipped++;
continue;
}
if (eq(namea, nameb)) {
nb++;
break;
}
if (ordered) {
@ -296,8 +300,8 @@ public class TestDistributedSearch extends TestCase {
}
if (na != nb) {
return ".size()=="+na+","+nb;
if (a.size()-aSkipped != b.size()-bSkipped) {
return ".size()=="+a.size()+","+b.size()+"skipped="+aSkipped+","+bSkipped;
}
return null;
@ -523,10 +527,17 @@ public class TestDistributedSearch extends TestCase {
query("q","now their fox sat had put","fl","*,score",
"debugQuery", "true");
// TODO: This test currently fails because debug info is obtained only
// on shards with matches.
/***
query("q","matchesnothing","fl","*,score",
"debugQuery", "true");
***/
query("q","matchesnothing","fl","*,score");
query("q","*:*", "rows",100, "facet","true", "facet.field",t1);
query("q","*:*", "rows",100, "facet","true", "facet.field",t1, "facet.limit",-1, "facet.sort",true);
query("q","*:*", "rows",100, "facet","true", "facet.field",t1,"facet.limit",1);
query("q","*:*", "rows",100, "facet","true", "facet.query","quick", "facet.query","all", "facet.query","*:*");
query("q","*:*", "rows",100, "facet","true", "facet.field",t1, "facet.offset",1);