Example usage for org.apache.lucene.spatial.bbox BBoxStrategy makeShapeValueSource

List of usage examples for org.apache.lucene.spatial.bbox BBoxStrategy makeShapeValueSource

Introduction

In this page you can find the example usage for org.apache.lucene.spatial.bbox BBoxStrategy makeShapeValueSource.

Prototype

   public ShapeValuesSource makeShapeValueSource() 

Source Link

Document

Provides access to each rectangle per document as a ShapeValuesSource

Usage

From source file:org.apache.solr.schema.BBoxField.java

License:Apache License

@Override
protected ValueSource getValueSourceFromSpatialArgs(QParser parser, SchemaField field, SpatialArgs spatialArgs,
        String scoreParam, BBoxStrategy strategy) {
    if (scoreParam == null) {
        return null;
    }/*w  ww .j a  va 2  s.co m*/
    switch (scoreParam) {
    //TODO move these to superclass after LUCENE-5804 ?
    case OVERLAP_RATIO:
        double queryTargetProportion = 0.25;//Suggested default; weights towards target area

        String v = parser.getParam(PARAM_QUERY_TARGET_PROPORTION);
        if (v != null)
            queryTargetProportion = Double.parseDouble(v);

        double minSideLength = 0.0;
        v = parser.getParam(PARAM_MIN_SIDE_LENGTH);
        if (v != null)
            minSideLength = Double.parseDouble(v);

        return new BBoxOverlapRatioValueSource(strategy.makeShapeValueSource(), ctx.isGeo(),
                (Rectangle) spatialArgs.getShape(), queryTargetProportion, minSideLength);

    case AREA:
        return new ShapeAreaValueSource(strategy.makeShapeValueSource(), ctx, ctx.isGeo());

    case AREA2D:
        return new ShapeAreaValueSource(strategy.makeShapeValueSource(), ctx, false);

    default:
        return super.getValueSourceFromSpatialArgs(parser, field, spatialArgs, scoreParam, strategy);
    }
}