Search in sources :

Example 6 with UnsupportedSpatialOperation

use of org.apache.lucene.spatial.query.UnsupportedSpatialOperation in project elasticsearch by elastic.

the class GeoFilterIT method testRelationSupport.

protected static boolean testRelationSupport(SpatialOperation relation) {
    if (relation == SpatialOperation.IsDisjointTo) {
        // disjoint works in terms of intersection
        relation = SpatialOperation.Intersects;
    }
    try {
        GeohashPrefixTree tree = new GeohashPrefixTree(SpatialContext.GEO, 3);
        RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(tree, "area");
        Shape shape = SpatialContext.GEO.makePoint(0, 0);
        SpatialArgs args = new SpatialArgs(relation, shape);
        strategy.makeQuery(args);
        return true;
    } catch (UnsupportedSpatialOperation e) {
        final SpatialOperation finalRelation = relation;
        ESLoggerFactory.getLogger(GeoFilterIT.class.getName()).info((Supplier<?>) () -> new ParameterizedMessage("Unsupported spatial operation {}", finalRelation), e);
        return false;
    }
}
Also used : SpatialArgs(org.apache.lucene.spatial.query.SpatialArgs) UnsupportedSpatialOperation(org.apache.lucene.spatial.query.UnsupportedSpatialOperation) Shape(org.locationtech.spatial4j.shape.Shape) RecursivePrefixTreeStrategy(org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy) Supplier(org.apache.logging.log4j.util.Supplier) ParameterizedMessage(org.apache.logging.log4j.message.ParameterizedMessage) UnsupportedSpatialOperation(org.apache.lucene.spatial.query.UnsupportedSpatialOperation) SpatialOperation(org.apache.lucene.spatial.query.SpatialOperation) GeohashPrefixTree(org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree)

Aggregations

SpatialOperation (org.apache.lucene.spatial.query.SpatialOperation)6 UnsupportedSpatialOperation (org.apache.lucene.spatial.query.UnsupportedSpatialOperation)6 Shape (org.locationtech.spatial4j.shape.Shape)5 Query (org.apache.lucene.search.Query)3 BooleanQuery (org.apache.lucene.search.BooleanQuery)2 ConstantScoreQuery (org.apache.lucene.search.ConstantScoreQuery)2 TermQuery (org.apache.lucene.search.TermQuery)2 SpatialArgs (org.apache.lucene.spatial.query.SpatialArgs)2 Point (org.locationtech.spatial4j.shape.Point)2 Rectangle (org.locationtech.spatial4j.shape.Rectangle)2 ArrayList (java.util.ArrayList)1 ParameterizedMessage (org.apache.logging.log4j.message.ParameterizedMessage)1 Supplier (org.apache.logging.log4j.util.Supplier)1 TermInSetQuery (org.apache.lucene.search.TermInSetQuery)1 RecursivePrefixTreeStrategy (org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy)1 Cell (org.apache.lucene.spatial.prefix.tree.Cell)1 CellIterator (org.apache.lucene.spatial.prefix.tree.CellIterator)1 GeohashPrefixTree (org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree)1 SpatialPrefixTree (org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree)1 ShapePredicateValueSource (org.apache.lucene.spatial.util.ShapePredicateValueSource)1