use of org.apache.solr.common.params.FacetParams.FacetRangeMethod in project lucene-solr by apache.
the class SimpleFacetsTest method testRangeFacetingBadRequest.
public void testRangeFacetingBadRequest() {
String field = "range_facet_l";
ignoreException(".");
try {
for (FacetRangeMethod method : FacetRangeMethod.values()) {
assertQEx("Test facet.range bad requests", "range facet 'end' comes before 'start'", req("q", "*:*", "facet", "true", "facet.range", field, "facet.range.method", method.toString(), "facet.range.start", "45", "facet.range.end", "43", "facet.range.gap", "10"), ErrorCode.BAD_REQUEST);
assertQEx("Test facet.range bad requests", "range facet infinite loop (is gap negative? did the math overflow?)", req("q", "*:*", "facet", "true", "facet.range", field, "facet.range.method", method.toString(), "facet.range.start", "43", "facet.range.end", "45", "facet.range.gap", "-1"), ErrorCode.BAD_REQUEST);
assertQEx("Test facet.range bad requests", "range facet infinite loop: gap is either zero, or too small relative start/end and caused underflow", req("q", "*:*", "facet", "true", "facet.range", field, "facet.range.method", method.toString(), "facet.range.start", "43", "facet.range.end", "45", "facet.range.gap", "0"), ErrorCode.BAD_REQUEST);
assertQEx("Test facet.range bad requests", "Missing required parameter", req("q", "*:*", "facet", "true", "facet.range", field, "facet.range.method", method.toString(), "facet.range.end", "45", "facet.range.gap", "5"), ErrorCode.BAD_REQUEST);
assertQEx("Test facet.range bad requests", "Missing required parameter", req("q", "*:*", "facet", "true", "facet.range", field, "facet.range.method", method.toString(), "facet.range.start", "43", "facet.range.gap", "5"), ErrorCode.BAD_REQUEST);
assertQEx("Test facet.range bad requests", "Missing required parameter", req("q", "*:*", "facet", "true", "facet.range", field, "facet.range.method", method.toString(), "facet.range.start", "43", "facet.range.end", "45"), ErrorCode.BAD_REQUEST);
assertQEx("Test facet.range bad requests", "Unable to range facet on field", req("q", "*:*", "facet", "true", "facet.range", "contains_s1", "facet.range.method", method.toString(), "facet.range.start", "43", "facet.range.end", "45", "facet.range.gap", "5"), ErrorCode.BAD_REQUEST);
assertQEx("Test facet.range bad requests", "foo is not a valid method for range faceting", req("q", "*:*", "facet", "true", "facet.range", field, "facet.range.method", "foo", "facet.range.start", "43", "facet.range.end", "45", "facet.range.gap", "5"), ErrorCode.BAD_REQUEST);
assertQEx("Test facet.range bad requests", "foo is not a valid type of for range 'include' information", req("q", "*:*", "facet", "true", "facet.range", field, "facet.range.method", method.toString(), "facet.range.start", "43", "facet.range.end", "45", "facet.range.gap", "5", "facet.range.include", "foo"), ErrorCode.BAD_REQUEST);
}
} finally {
resetExceptionIgnores();
}
}
use of org.apache.solr.common.params.FacetParams.FacetRangeMethod in project lucene-solr by apache.
the class RangeFacetProcessor method getFacetRangeCounts.
/**
* Returns a list of value constraints and the associated facet counts
* for each facet range specified by the given {@link RangeFacetRequest}
*/
public void getFacetRangeCounts(RangeFacetRequest rangeFacetRequest, NamedList<Object> resOuter) throws IOException, SyntaxError {
final IndexSchema schema = searcher.getSchema();
final String key = rangeFacetRequest.getKey();
final String f = rangeFacetRequest.facetOn;
FacetRangeMethod method = rangeFacetRequest.getMethod();
final SchemaField sf = schema.getField(f);
final FieldType ft = sf.getType();
if (method.equals(FacetRangeMethod.DV)) {
assert ft instanceof TrieField || ft.isPointField();
resOuter.add(key, getFacetRangeCountsDocValues(rangeFacetRequest));
} else {
resOuter.add(key, getFacetRangeCounts(rangeFacetRequest));
}
}
Aggregations