Search in sources :

Example 41 with Distance

use of org.springframework.data.geo.Distance in project nixmash-blog by mintster.

the class SolrLocationTests method testFindByLocationCriteria.

@Test
public void testFindByLocationCriteria() {
    Point location = new Point(22.15, -90.85);
    Criteria criteria = new Criteria("store").near(location, new Distance(5));
    Page<Product> result = solrOperations.queryForPage(new SimpleQuery(criteria), Product.class);
    Assert.assertEquals(1, result.getTotalElements());
    Assert.assertEquals(locatedInYonkers.getId(), result.getContent().get(0).getId());
}
Also used : SimpleQuery(org.springframework.data.solr.core.query.SimpleQuery) Product(com.nixmash.blog.solr.model.Product) Point(org.springframework.data.geo.Point) SimpleStringCriteria(org.springframework.data.solr.core.query.SimpleStringCriteria) Criteria(org.springframework.data.solr.core.query.Criteria) Distance(org.springframework.data.geo.Distance) Test(org.junit.Test)

Example 42 with Distance

use of org.springframework.data.geo.Distance in project nixmash-blog by mintster.

the class SolrLocationTests method testFindByNear.

@Test
public void testFindByNear() {
    List<Product> found = repo.findByLocationNear(new Point(22.15, -90.85), new Distance(5));
    locationAsserts(found);
}
Also used : Product(com.nixmash.blog.solr.model.Product) Point(org.springframework.data.geo.Point) Distance(org.springframework.data.geo.Distance) Test(org.junit.Test)

Example 43 with Distance

use of org.springframework.data.geo.Distance in project nixmash-blog by mintster.

the class SolrLocationTests method testFindByLocationWithin.

@Test
public void testFindByLocationWithin() {
    List<Product> found = repo.findByLocationWithin(new Point(22.15, -90.85), new Distance(5));
    locationAsserts(found);
}
Also used : Product(com.nixmash.blog.solr.model.Product) Point(org.springframework.data.geo.Point) Distance(org.springframework.data.geo.Distance) Test(org.junit.Test)

Example 44 with Distance

use of org.springframework.data.geo.Distance in project nixmash-blog by mintster.

the class SolrLocationTests method testFindByAnnotatedQueryNear.

@Test
public void testFindByAnnotatedQueryNear() {
    List<Product> found = repo.findByLocationSomewhereNear(new Point(22.15, -90.85), new Distance(5));
    locationAsserts(found);
}
Also used : Product(com.nixmash.blog.solr.model.Product) Point(org.springframework.data.geo.Point) Distance(org.springframework.data.geo.Distance) Test(org.junit.Test)

Aggregations

Distance (org.springframework.data.geo.Distance)44 Test (org.junit.jupiter.api.Test)34 Point (org.springframework.data.geo.Point)32 GeoJsonPoint (org.springframework.data.mongodb.core.geo.GeoJsonPoint)17 Query (org.springframework.data.mongodb.core.query.Query)9 Test (org.junit.Test)6 Product (com.nixmash.blog.solr.model.Product)5 Document (org.bson.Document)5 Circle (org.springframework.data.geo.Circle)5 Document (org.springframework.data.mongodb.core.mapping.Document)5 PartTree (org.springframework.data.repository.query.parser.PartTree)5 Sphere (org.springframework.data.mongodb.core.geo.Sphere)4 Arrays (java.util.Arrays)3 Sort (org.springframework.data.domain.Sort)3 Metrics (org.springframework.data.geo.Metrics)3 MongoClient (com.mongodb.reactivestreams.client.MongoClient)2 Method (java.lang.reflect.Method)2 Map (java.util.Map)2 BlockingQueue (java.util.concurrent.BlockingQueue)2 LinkedBlockingDeque (java.util.concurrent.LinkedBlockingDeque)2