use of com.cloudant.client.api.model.SearchResult.SearchResultRow in project java-cloudant by cloudant.
the class SearchTests method multiValueDrillDownTest.
@Test
public void multiValueDrillDownTest() {
// do a faceted search for multi-value drilldown
Search srch = db.search("views101/animals");
SearchResult<Animal> rslt = srch.includeDocs(true).drillDown("diet", "carnivore", "omnivore").querySearchResult("class:mammal", Animal.class);
assertNotNull(rslt);
assertEquals(4, rslt.getTotalRows());
List<String> ids = new ArrayList<String>();
for (SearchResultRow row : rslt.getRows()) {
ids.add(row.getId());
}
List<String> expectedIds = Arrays.asList("panda", "aardvark", "badger", "lemur");
assertTrue(ids.containsAll(expectedIds));
}
use of com.cloudant.client.api.model.SearchResult.SearchResultRow in project java-cloudant by cloudant.
the class SearchTests method searchCountsTest.
@Test
public void searchCountsTest() {
// do a faceted search for counts
Search srch = db.search("views101/animals");
SearchResult<Animal> rslt = srch.limit(10).includeDocs(true).counts(new String[] { "class", "diet" }).querySearchResult("l*", Animal.class);
assertNotNull(rslt);
assertNotNull(rslt.getCounts());
assertEquals(2, rslt.getCounts().keySet().size());
assertEquals(1, rslt.getCounts().get("class").keySet().size());
assertEquals(new Long(2), rslt.getCounts().get("class").get("mammal"));
assertEquals(2, rslt.getCounts().get("diet").keySet().size());
assertEquals(new Long(1), rslt.getCounts().get("diet").get("herbivore"));
assertEquals(new Long(1), rslt.getCounts().get("diet").get("omnivore"));
assertNotNull(rslt.getBookmark());
assertEquals(0, rslt.getGroups().size());
assertEquals(2, rslt.getRows().size());
for (@SuppressWarnings("rawtypes") SearchResultRow r : rslt.getRows()) {
assertNotNull(r.getDoc());
assertNotNull(r.getFields());
assertNotNull(r.getId());
assertNotNull(r.getOrder());
}
}
Aggregations