mirror of https://github.com/apache/lucene.git
SOLR-13206: Fix AIOOBE when group.facet is specified with group.query
group.facet is supported only for group.field. When group.facet is used with group.query, then return proper error code
This commit is contained in:
parent
0de627ee26
commit
1fc416404c
|
@ -81,6 +81,11 @@ Improvements
|
|||
* SOLR-12368: Support InPlace DV updates for a field that does not yet exist in any documents
|
||||
(hossman, Simon Willnauer, Adrien Grand, Munendra S N)
|
||||
|
||||
Bug Fixes
|
||||
----------------------
|
||||
|
||||
* SOLR-13206: Fix AIOOBE when group.facet is specified with group.query and return proper error code. (Marek, Munendra S N)
|
||||
|
||||
================== 8.2.0 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
|
||||
|
|
|
@ -38,6 +38,7 @@ import java.util.concurrent.Semaphore;
|
|||
import java.util.function.Predicate;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.lucene.index.ExitableDirectoryReader;
|
||||
import org.apache.lucene.index.LeafReader;
|
||||
import org.apache.lucene.index.LeafReaderContext;
|
||||
|
@ -705,7 +706,8 @@ public class SimpleFacets {
|
|||
String prefix,
|
||||
Predicate<BytesRef> termFilter) throws IOException {
|
||||
GroupingSpecification groupingSpecification = rb.getGroupingSpec();
|
||||
final String groupField = groupingSpecification != null ? groupingSpecification.getFields()[0] : null;
|
||||
String[] groupFields = groupingSpecification != null? groupingSpecification.getFields(): null;
|
||||
final String groupField = ArrayUtils.isNotEmpty(groupFields) ? groupFields[0] : null;
|
||||
if (groupField == null) {
|
||||
throw new SolrException (
|
||||
SolrException.ErrorCode.BAD_REQUEST,
|
||||
|
|
|
@ -3304,6 +3304,39 @@ public class SimpleFacetsTest extends SolrTestCaseJ4 {
|
|||
|
||||
}
|
||||
|
||||
public void testGroupFacetErrors() {
|
||||
ModifiableSolrParams params = params("q", "*:*", "group", "true", "group.query", "myfield_s:*",
|
||||
"facet", "true", "group.facet", "true");
|
||||
|
||||
// with facet.field
|
||||
SolrException ex = expectThrows(SolrException.class, () -> {
|
||||
h.query(req(params, "facet.field", "myfield_s"));
|
||||
});
|
||||
assertEquals(ErrorCode.BAD_REQUEST.code, ex.code());
|
||||
assertTrue(ex.getMessage().contains("Specify the group.field as parameter or local parameter"));
|
||||
|
||||
// with facet.query
|
||||
ex = expectThrows(SolrException.class, () -> {
|
||||
h.query(req(params, "facet.query", "myfield_s:*"));
|
||||
});
|
||||
assertEquals(ErrorCode.BAD_REQUEST.code, ex.code());
|
||||
assertTrue(ex.getMessage().contains("Specify the group.field as parameter or local parameter"));
|
||||
|
||||
// with facet.range
|
||||
ex = expectThrows(SolrException.class, () -> h.query(req(params, "facet.range", "range_facet_l",
|
||||
"facet.range.start", "43", "facet.range.end", "450", "facet.range.gap", "10"))
|
||||
);
|
||||
assertEquals(ErrorCode.BAD_REQUEST.code, ex.code());
|
||||
assertTrue(ex.getMessage().contains("Specify the group.field as parameter or local parameter"));
|
||||
|
||||
// with facet.interval
|
||||
ex = expectThrows(SolrException.class, () -> h.query(req(params, "facet.interval", "range_facet_l",
|
||||
"f.range_facet_l.facet.interval.set", "(43,60]"))
|
||||
);
|
||||
assertEquals(ErrorCode.BAD_REQUEST.code, ex.code());
|
||||
assertTrue(ex.getMessage().contains("Interval Faceting can't be used with group.facet"));
|
||||
}
|
||||
|
||||
public void testRangeFacetingBadRequest() {
|
||||
String field = "range_facet_l";
|
||||
ignoreException(".");
|
||||
|
|
Loading…
Reference in New Issue