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));
}
}
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;
}
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;
}
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();
}
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);
}
}
Aggregations