Search in sources :

Example 6 with TrieField

use of org.apache.solr.schema.TrieField in project lucene-solr by apache.

the class RangeFacetRequest method createCalculator.

/**
   * Creates the right instance of {@link org.apache.solr.handler.component.RangeFacetRequest.RangeEndpointCalculator}
   * depending on the field type of the schema field
   */
private RangeEndpointCalculator<? extends Comparable<?>> createCalculator() {
    RangeEndpointCalculator<?> calc;
    FieldType ft = schemaField.getType();
    if (ft instanceof TrieField) {
        switch(ft.getNumberType()) {
            case FLOAT:
                calc = new FloatRangeEndpointCalculator(this);
                break;
            case DOUBLE:
                calc = new DoubleRangeEndpointCalculator(this);
                break;
            case INTEGER:
                calc = new IntegerRangeEndpointCalculator(this);
                break;
            case LONG:
                calc = new LongRangeEndpointCalculator(this);
                break;
            case DATE:
                calc = new DateRangeEndpointCalculator(this, null);
                break;
            default:
                throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on Trie field of unexpected type:" + this.facetOn);
        }
    } else if (ft instanceof DateRangeField) {
        calc = new DateRangeEndpointCalculator(this, null);
    } else if (ft.isPointField()) {
        switch(ft.getNumberType()) {
            case FLOAT:
                calc = new FloatRangeEndpointCalculator(this);
                break;
            case DOUBLE:
                calc = new DoubleRangeEndpointCalculator(this);
                break;
            case INTEGER:
                calc = new IntegerRangeEndpointCalculator(this);
                break;
            case LONG:
                calc = new LongRangeEndpointCalculator(this);
                break;
            case DATE:
                calc = new DateRangeEndpointCalculator(this, null);
                break;
            default:
                throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on Point field of unexpected type:" + this.facetOn);
        }
    } else {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on field:" + schemaField);
    }
    return calc;
}
Also used : TrieField(org.apache.solr.schema.TrieField) SolrException(org.apache.solr.common.SolrException) DateRangeField(org.apache.solr.schema.DateRangeField) FieldType(org.apache.solr.schema.FieldType)

Aggregations

FieldType (org.apache.solr.schema.FieldType)6 TrieField (org.apache.solr.schema.TrieField)6 SolrException (org.apache.solr.common.SolrException)4 SchemaField (org.apache.solr.schema.SchemaField)2 FacetRangeMethod (org.apache.solr.common.params.FacetParams.FacetRangeMethod)1 DateRangeField (org.apache.solr.schema.DateRangeField)1 IndexSchema (org.apache.solr.schema.IndexSchema)1 PointField (org.apache.solr.schema.PointField)1