use of play.modules.solr.Query in project play-cookbook by spinscale.
the class SolrSearchTest method testPagination.
@Test
public void testPagination() throws Exception {
Car.deleteAll();
clearSolrServerIndex();
Fixtures.loadModels("test-data-many-cars.yml");
List<Model> result = new Query("brand_s:*", Car.class).limit(10).start(10).fetch();
assertEquals(3, result.size());
}
use of play.modules.solr.Query in project play-cookbook by spinscale.
the class SolrSearchTest method testQuery.
@Test
public void testQuery() {
List<User> users = new Query("name:alex", User.class).fetch();
assertEquals(1, users.size());
assertEquals("alex", users.get(0).name);
}
use of play.modules.solr.Query in project play-cookbook by spinscale.
the class SolrSearchTest method testQueryResultIds.
@Test
public void testQueryResultIds() {
User u = User.find("byName", "alex").first();
List<String> users = new Query("name:alex", User.class).fetchIds();
assertEquals(u.id.toString(), users.get(0));
}
use of play.modules.solr.Query in project play-cookbook by spinscale.
the class SolrSearchTest method ensureDeletionWorks.
@Test
public void ensureDeletionWorks() throws Exception {
List<Car> cars = Car.findAll();
for (Car car : cars) {
car.delete();
}
assertEquals(0, new Query("brand_s:*", Car.class).fetchIds().size());
}
use of play.modules.solr.Query in project play-cookbook by spinscale.
the class SolrSearchTest method testOffset.
@Test
public void testOffset() throws Exception {
Car.deleteAll();
clearSolrServerIndex();
Fixtures.loadModels("test-data-many-cars.yml");
List<Model> result = new Query("brand_s:*", Car.class).limit(5).start(0).fetch();
assertEquals(5, result.size());
result = new Query("brand_s:*", Car.class).limit(5).start(5).fetch();
assertEquals(5, result.size());
result = new Query("brand_s:*", Car.class).limit(5).start(10).fetch();
assertEquals(3, result.size());
}