Search in sources :

Example 1 with TrieField

use of org.apache.solr.schema.TrieField 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)

Example 2 with TrieField

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

the class RangeEndpointCalculator method create.

public static RangeEndpointCalculator<? extends Comparable<?>> create(RangeFacetRequest request) {
    final SchemaField sf = request.getField();
    final FieldType ft = sf.getType();
    final RangeEndpointCalculator<?> calc;
    if (ft instanceof TrieField) {
        switch(ft.getNumberType()) {
            case FLOAT:
                calc = new FloatRangeEndpointCalculator(request);
                break;
            case DOUBLE:
                calc = new DoubleRangeEndpointCalculator(request);
                break;
            case INTEGER:
                calc = new IntegerRangeEndpointCalculator(request);
                break;
            case LONG:
                calc = new LongRangeEndpointCalculator(request);
                break;
            case DATE:
                calc = new DateRangeEndpointCalculator(request, null);
                break;
            default:
                throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on tried field of unexpected type:" + sf.getName());
        }
    } else {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on field:" + sf);
    }
    return calc;
}
Also used : SchemaField(org.apache.solr.schema.SchemaField) TrieField(org.apache.solr.schema.TrieField) SolrException(org.apache.solr.common.SolrException) FieldType(org.apache.solr.schema.FieldType)

Example 3 with TrieField

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

the class FacetRangeProcessor method getNumericCalc.

public static Calc getNumericCalc(SchemaField sf) {
    Calc calc;
    final FieldType ft = sf.getType();
    if (ft instanceof TrieField) {
        switch(ft.getNumberType()) {
            case FLOAT:
                calc = new FloatCalc(sf);
                break;
            case DOUBLE:
                calc = new DoubleCalc(sf);
                break;
            case INTEGER:
                calc = new IntCalc(sf);
                break;
            case LONG:
                calc = new LongCalc(sf);
                break;
            case DATE:
                calc = new DateCalc(sf, null);
                break;
            default:
                throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Expected numeric field type :" + sf);
        }
    } else if (ft instanceof PointField) {
        // TODO, this is the same in Trie and Point now
        switch(ft.getNumberType()) {
            case FLOAT:
                calc = new FloatCalc(sf);
                break;
            case DOUBLE:
                calc = new DoubleCalc(sf);
                break;
            case INTEGER:
                calc = new IntCalc(sf);
                break;
            case LONG:
                calc = new LongCalc(sf);
                break;
            case DATE:
                calc = new DateCalc(sf, null);
                break;
            default:
                throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Expected numeric field type :" + sf);
        }
    } else {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Expected numeric field type :" + sf);
    }
    return calc;
}
Also used : PointField(org.apache.solr.schema.PointField) TrieField(org.apache.solr.schema.TrieField) SolrException(org.apache.solr.common.SolrException) FieldType(org.apache.solr.schema.FieldType)

Example 4 with TrieField

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

the class FacetRangeProcessor method getRangeCounts.

private SimpleOrderedMap<Object> getRangeCounts() throws IOException {
    final FieldType ft = sf.getType();
    if (ft instanceof TrieField) {
        switch(ft.getNumberType()) {
            case FLOAT:
                calc = new FloatCalc(sf);
                break;
            case DOUBLE:
                calc = new DoubleCalc(sf);
                break;
            case INTEGER:
                calc = new IntCalc(sf);
                break;
            case LONG:
                calc = new LongCalc(sf);
                break;
            case DATE:
                calc = new DateCalc(sf, null);
                break;
            default:
                throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on tried field of unexpected type:" + freq.field);
        }
    } else {
        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unable to range facet on field:" + sf);
    }
    createRangeList();
    return getRangeCountsIndexed();
}
Also used : TrieField(org.apache.solr.schema.TrieField) SolrException(org.apache.solr.common.SolrException) FieldType(org.apache.solr.schema.FieldType)

Example 5 with TrieField

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

the class TestTrie method checkPrecisionSteps.

private void checkPrecisionSteps(String fieldType) {
    FieldType type = h.getCore().getLatestSchema().getFieldType(fieldType);
    if (type instanceof TrieField) {
        TrieField field = (TrieField) type;
        assertTrue(field.getPrecisionStep() > 0 && field.getPrecisionStep() < 64);
    }
}
Also used : TrieField(org.apache.solr.schema.TrieField) 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