Example usage for org.apache.solr.common.params SolrParams getDouble

List of usage examples for org.apache.solr.common.params SolrParams getDouble

Introduction

In this page you can find the example usage for org.apache.solr.common.params SolrParams getDouble.

Prototype

public Double getDouble(String param) 

Source Link

Document

Returns the Float value of the param, or null if not set Use this method only when you want to be explicit about absence of a value (null) vs the default value zero (0.0d).

Usage

From source file:CartesianTierQParserPlugin.java

License:Apache License

public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {
    return new QParser(qstr, localParams, params, req) {

        public Query parse() throws ParseException {
            final Double x = localParams.getDouble("x");
            final Double y = localParams.getDouble("y");

            final String fieldPrefix = localParams.get("prefix", tierPrefix);
            final Double distance = localParams.getDouble("dist");
            //GSI: kind of funky passing in an empty string, but AFAICT, it is safe b/c we don't want to assume tier prefix stuff
            CartesianPolyFilterBuilder cpfb = new CartesianPolyFilterBuilder(fieldPrefix);
            //Get the box based on this point and our distance
            final Shape shape = cpfb.getBoxShape(x, y, distance);
            final List<Double> boxIds = shape.getArea();

            //Sort them, so they are in order, which will be faster for termdocs in the tier filter
            Collections.sort(boxIds);
            //Get the field type so we can properly encode the data
            IndexSchema schema = req.getSchema();
            FieldType ft = schema.getFieldTypeNoEx(shape.getTierId());

            //Create the Filter and wrap it in a constant score query
            Filter filter = new TierFilter(shape.getTierId(), ft, boxIds);
            return new SolrConstantScoreQuery(filter);
        }/*from w  ww. jav a  2  s  .  c o  m*/
    };
}