Search in sources :

Example 11 with SpatialOperation

use of org.apache.lucene.spatial.query.SpatialOperation in project lucene-solr by apache.

the class TestBBoxStrategy method testOperations.

@Test
@Repeat(iterations = 15)
public void testOperations() throws IOException {
    //setup
    if (random().nextInt(4) > 0) {
        //75% of the time choose geo (more interesting to test)
        this.ctx = SpatialContext.GEO;
    } else {
        SpatialContextFactory factory = new SpatialContextFactory();
        factory.geo = false;
        factory.worldBounds = new RectangleImpl(-300, 300, -100, 100, null);
        this.ctx = factory.newSpatialContext();
    }
    this.strategy = BBoxStrategy.newInstance(ctx, "bbox");
    //test we can disable docValues for predicate tests
    if (random().nextBoolean()) {
        FieldType fieldType = new FieldType(((BBoxStrategy) strategy).getFieldType());
        fieldType.setDocValuesType(DocValuesType.NONE);
        strategy = new BBoxStrategy(ctx, strategy.getFieldName(), fieldType);
    }
    for (SpatialOperation operation : SpatialOperation.values()) {
        if (operation == SpatialOperation.Overlaps)
            //unsupported
            continue;
        testOperationRandomShapes(operation);
        deleteAll();
        commit();
    }
}
Also used : SpatialContextFactory(org.locationtech.spatial4j.context.SpatialContextFactory) RectangleImpl(org.locationtech.spatial4j.shape.impl.RectangleImpl) SpatialOperation(org.apache.lucene.spatial.query.SpatialOperation) FieldType(org.apache.lucene.document.FieldType) Test(org.junit.Test) Repeat(com.carrotsearch.randomizedtesting.annotations.Repeat)

Aggregations

SpatialOperation (org.apache.lucene.spatial.query.SpatialOperation)11 Shape (org.locationtech.spatial4j.shape.Shape)7 UnsupportedSpatialOperation (org.apache.lucene.spatial.query.UnsupportedSpatialOperation)6 Query (org.apache.lucene.search.Query)5 SpatialArgs (org.apache.lucene.spatial.query.SpatialArgs)5 Test (org.junit.Test)3 Point (org.locationtech.spatial4j.shape.Point)3 Rectangle (org.locationtech.spatial4j.shape.Rectangle)3 Repeat (com.carrotsearch.randomizedtesting.annotations.Repeat)2 BooleanQuery (org.apache.lucene.search.BooleanQuery)2 ConstantScoreQuery (org.apache.lucene.search.ConstantScoreQuery)2 TermQuery (org.apache.lucene.search.TermQuery)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ParameterizedMessage (org.apache.logging.log4j.message.ParameterizedMessage)1 Supplier (org.apache.logging.log4j.util.Supplier)1 FieldType (org.apache.lucene.document.FieldType)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