use of org.apache.lucene.spatial.query.SpatialArgs in project lucene-solr by apache.
the class TestPointVectorStrategy method testCircleShapeSupport.
@Test
public void testCircleShapeSupport() {
this.strategy = PointVectorStrategy.newInstance(ctx, getClass().getSimpleName());
Circle circle = ctx.makeCircle(ctx.makePoint(0, 0), 10);
SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, circle);
Query query = this.strategy.makeQuery(args);
assertNotNull(query);
}
use of org.apache.lucene.spatial.query.SpatialArgs in project lucene-solr by apache.
the class JtsPolygonTest method testBadPrefixTreePrune.
/**
* A PrefixTree pruning optimization gone bad.
* See <a href="https://issues.apache.org/jira/browse/LUCENE-4770">LUCENE-4770</a>.
*/
@Test
public void testBadPrefixTreePrune() throws Exception {
Shape area = ctx.readShapeFromWkt("POLYGON((-122.83 48.57, -122.77 48.56, -122.79 48.53, -122.83 48.57))");
SpatialPrefixTree trie = new QuadPrefixTree(ctx, 12);
TermQueryPrefixTreeStrategy strategy = new TermQueryPrefixTreeStrategy(trie, "geo");
Document doc = new Document();
doc.add(new TextField("id", "1", Store.YES));
Field[] fields = strategy.createIndexableFields(area, 0.025);
for (Field field : fields) {
doc.add(field);
}
addDocument(doc);
Point upperleft = ctx.makePoint(-122.88, 48.54);
Point lowerright = ctx.makePoint(-122.82, 48.62);
Query query = strategy.makeQuery(new SpatialArgs(SpatialOperation.Intersects, ctx.makeRectangle(upperleft, lowerright)));
commit();
TopDocs search = indexSearcher.search(query, 10);
ScoreDoc[] scoreDocs = search.scoreDocs;
for (ScoreDoc scoreDoc : scoreDocs) {
System.out.println(indexSearcher.doc(scoreDoc.doc));
}
assertEquals(1, search.totalHits);
}
use of org.apache.lucene.spatial.query.SpatialArgs in project lucene-solr by apache.
the class JtsPolygonTest method testCloseButNoMatch.
@Test
public /** LUCENE-4464 */
void testCloseButNoMatch() throws Exception {
getAddAndVerifyIndexedDocuments("LUCENE-4464.txt");
SpatialArgs args = q("POLYGON((-93.18100824442227 45.25676372469945," + "-93.23182001200654 45.21421290799412," + "-93.16315546122038 45.23742639412364," + "-93.18100824442227 45.25676372469945))", LUCENE_4464_distErrPct);
SearchResults got = executeQuery(strategy.makeQuery(args), 100);
assertEquals(1, got.numFound);
assertEquals("poly2", got.results.get(0).document.get("id"));
//did not find poly 1 !
}
use of org.apache.lucene.spatial.query.SpatialArgs in project lucene-solr by apache.
the class SpatialPrefixTreeTest method testBadPrefixTreePrune.
/**
* A PrefixTree pruning optimization gone bad, applicable when optimize=true.
* See <a href="https://issues.apache.org/jira/browse/LUCENE-4770">LUCENE-4770</a>.
*/
@Test
public void testBadPrefixTreePrune() throws Exception {
trie = new QuadPrefixTree(ctx, 12);
TermQueryPrefixTreeStrategy strategy = new TermQueryPrefixTreeStrategy(trie, "geo");
Document doc = new Document();
doc.add(new TextField("id", "1", Store.YES));
Shape area = ctx.makeRectangle(-122.82, -122.78, 48.54, 48.56);
Field[] fields = strategy.createIndexableFields(area, 0.025);
for (Field field : fields) {
doc.add(field);
}
addDocument(doc);
Point upperleft = ctx.makePoint(-122.88, 48.54);
Point lowerright = ctx.makePoint(-122.82, 48.62);
Query query = strategy.makeQuery(new SpatialArgs(SpatialOperation.Intersects, ctx.makeRectangle(upperleft, lowerright)));
commit();
TopDocs search = indexSearcher.search(query, 10);
ScoreDoc[] scoreDocs = search.scoreDocs;
for (ScoreDoc scoreDoc : scoreDocs) {
System.out.println(indexSearcher.doc(scoreDoc.doc));
}
assertEquals(1, search.totalHits);
}
use of org.apache.lucene.spatial.query.SpatialArgs in project lucene-solr by apache.
the class TestPointVectorStrategy method testInvalidQueryShape.
@Test(expected = UnsupportedOperationException.class)
public void testInvalidQueryShape() {
this.strategy = PointVectorStrategy.newInstance(ctx, getClass().getSimpleName());
Point point = ctx.makePoint(0, 0);
SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, point);
this.strategy.makeQuery(args);
}
Aggregations