Search in sources :

Example 1 with FacetRangeMethod

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();
    }
}
Also used : FacetRangeMethod(org.apache.solr.common.params.FacetParams.FacetRangeMethod)

Example 2 with FacetRangeMethod

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));
    }
}
Also used : SchemaField(org.apache.solr.schema.SchemaField) FacetRangeMethod(org.apache.solr.common.params.FacetParams.FacetRangeMethod) IndexSchema(org.apache.solr.schema.IndexSchema) TrieField(org.apache.solr.schema.TrieField) FieldType(org.apache.solr.schema.FieldType)

Aggregations

FacetRangeMethod (org.apache.solr.common.params.FacetParams.FacetRangeMethod)2 FieldType (org.apache.solr.schema.FieldType)1 IndexSchema (org.apache.solr.schema.IndexSchema)1 SchemaField (org.apache.solr.schema.SchemaField)1 TrieField (org.apache.solr.schema.TrieField)1