Search in sources :

Example 16 with Product

use of com.nixmash.blog.solr.model.Product 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 17 with Product

use of com.nixmash.blog.solr.model.Product 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 18 with Product

use of com.nixmash.blog.solr.model.Product in project nixmash-blog by mintster.

the class SolrLocationTests method testFindByNearWithBox.

@Test
public void testFindByNearWithBox() {
    // locatedinYonkers location: 22.17614, -90.87341
    List<Product> found = repo.findByLocationNear(new Box(new Point(22, -91), new Point(23, -90)));
    locationAsserts(found);
}
Also used : Product(com.nixmash.blog.solr.model.Product) Box(org.springframework.data.geo.Box) Point(org.springframework.data.geo.Point) Test(org.junit.Test)

Example 19 with Product

use of com.nixmash.blog.solr.model.Product in project nixmash-blog by mintster.

the class SolrLocationTests method missingLocationsProduceNegativePointValues.

@Test
public void missingLocationsProduceNegativePointValues() {
    Product product = SolrTestUtils.createProduct(1002);
    repo.save(product);
    assertNull(product.getLocation());
    assertThat(product.getPoint().getX(), is(lessThan((double) 0)));
}
Also used : Product(com.nixmash.blog.solr.model.Product) Test(org.junit.Test)

Example 20 with Product

use of com.nixmash.blog.solr.model.Product 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

Product (com.nixmash.blog.solr.model.Product)20 Test (org.junit.Test)10 Point (org.springframework.data.geo.Point)6 PageRequest (org.springframework.data.domain.PageRequest)5 Distance (org.springframework.data.geo.Distance)5 FacetFieldEntry (org.springframework.data.solr.core.query.result.FacetFieldEntry)4 GeoLocationException (com.nixmash.blog.solr.exceptions.GeoLocationException)2 ArrayList (java.util.ArrayList)2 SimpleQuery (org.springframework.data.solr.core.query.SimpleQuery)2 SimpleStringCriteria (org.springframework.data.solr.core.query.SimpleStringCriteria)2 Post (com.nixmash.blog.jpa.model.Post)1 ProductCategory (com.nixmash.blog.mvc.containers.ProductCategory)1 IProduct (com.nixmash.blog.solr.model.IProduct)1 PostDoc (com.nixmash.blog.solr.model.PostDoc)1 MessageFormat (java.text.MessageFormat)1 PagedListHolder (org.springframework.beans.support.PagedListHolder)1 Box (org.springframework.data.geo.Box)1 UncategorizedSolrException (org.springframework.data.solr.UncategorizedSolrException)1 Criteria (org.springframework.data.solr.core.query.Criteria)1 Query (org.springframework.data.solr.core.query.Query)1