mirror of https://github.com/apache/lucene.git
SOLR-13725: allow negative values for limit in TermsFacetMap
* when limit is negative all the facet values are returned * allow mincount=0 in TermsFacetMap.
This commit is contained in:
parent
c22379253c
commit
59fe7b7d9f
|
@ -224,6 +224,8 @@ Bug Fixes
|
|||
|
||||
* SOLR-13780: Fix ClassCastException in NestableJsonFacet (Tiago Martinho de Barros, Munendra S N)
|
||||
|
||||
* SOLR-13725: Allow negative values for limit in TermsFacetMap (Richard Walker, Munendra S N)
|
||||
|
||||
Other Changes
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -55,9 +55,6 @@ public class TermsFacetMap extends JsonFacetMap<TermsFacetMap> {
|
|||
* Defaults to 10 if not specified.
|
||||
*/
|
||||
public TermsFacetMap setLimit(int maximumBuckets) {
|
||||
if (maximumBuckets < 0) {
|
||||
throw new IllegalArgumentException("Parameter 'maximumBuckets' must be non-negative");
|
||||
}
|
||||
put("limit", maximumBuckets);
|
||||
return this;
|
||||
}
|
||||
|
@ -147,8 +144,8 @@ public class TermsFacetMap extends JsonFacetMap<TermsFacetMap> {
|
|||
* Defaults to 1 if not specified.
|
||||
*/
|
||||
public TermsFacetMap setMinCount(int minCount) {
|
||||
if (minCount < 1) {
|
||||
throw new IllegalArgumentException("Parameter 'minCount' must be a positive integer");
|
||||
if (minCount < 0) {
|
||||
throw new IllegalArgumentException("Parameter 'minCount' must be a non-negative integer");
|
||||
}
|
||||
put("mincount", minCount);
|
||||
return this;
|
||||
|
|
|
@ -54,15 +54,6 @@ public class TermsFacetMapTest extends SolrTestCaseJ4 {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRejectsNegativeBucketLimit() {
|
||||
final Throwable thrown = expectThrows(IllegalArgumentException.class, () -> {
|
||||
final TermsFacetMap termsFacet = new TermsFacetMap(ANY_FIELD_NAME)
|
||||
.setLimit(-1);
|
||||
});
|
||||
assertThat(thrown.getMessage(), containsString("must be non-negative"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStoresBucketLimitWithCorrectKey() {
|
||||
final TermsFacetMap termsFacet = new TermsFacetMap(ANY_FIELD_NAME)
|
||||
|
@ -129,9 +120,9 @@ public class TermsFacetMapTest extends SolrTestCaseJ4 {
|
|||
public void testRejectInvalidMinCount() {
|
||||
final Throwable thrown = expectThrows(IllegalArgumentException.class, () -> {
|
||||
final TermsFacetMap termsFacet = new TermsFacetMap(ANY_FIELD_NAME)
|
||||
.setMinCount(0);
|
||||
.setMinCount(-1);
|
||||
});
|
||||
assertThat(thrown.getMessage(), containsString("must be a positive integer"));
|
||||
assertThat(thrown.getMessage(), containsString("must be a non-negative integer"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -139,6 +130,8 @@ public class TermsFacetMapTest extends SolrTestCaseJ4 {
|
|||
final TermsFacetMap termsFacet = new TermsFacetMap(ANY_FIELD_NAME)
|
||||
.setMinCount(6);
|
||||
assertEquals(6, termsFacet.get("mincount"));
|
||||
termsFacet.setMinCount(0);
|
||||
assertEquals(0, termsFacet.get("mincount"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue