use of com.cloudant.client.api.Search in project java-cloudant by cloudant.
the class SearchTests method multipleDrillDownTest.
@Test
public /**
* Request a search with two drilldown queries against the views101
* design document. The design document only contains one animal
* that satisfies the drilldown requirements.
* Assert that the result is one animal in the class bird, and
* that the only existing min_length value of this animal is small.
*/
void multipleDrillDownTest() {
Search srch = db.search("views101/animals");
SearchResult<Animal> rslt = srch.includeDocs(true).counts(new String[] { "class", "diet" }).ranges("{ \"min_length\": {\"small\": \"[0 TO 1.0]\"," + "\"medium\": \"[1.1 TO 3.0]\", \"large\": \"[3.1 TO 9999999]\"} }").drillDown("class", "bird").drillDown("diet", "omnivore").querySearchResult("class:bird", Animal.class);
assertNotNull(rslt);
assertNotNull(rslt.getRanges());
assertEquals(1, rslt.getRanges().entrySet().size());
assertEquals(3, rslt.getRanges().get("min_length").entrySet().size());
assertEquals(new Long(1), rslt.getRanges().get("min_length").get("small"));
assertEquals(new Long(0), rslt.getRanges().get("min_length").get("medium"));
assertEquals(new Long(0), rslt.getRanges().get("min_length").get("large"));
}
use of com.cloudant.client.api.Search 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.Search in project java-cloudant by cloudant.
the class SearchTests method drillDownTest.
@Test
public void drillDownTest() {
// do a faceted search for drilldown
Search srch = db.search("views101/animals");
SearchResult<Animal> rslt = srch.includeDocs(true).counts(new String[] { "class", "diet" }).ranges("{ \"min_length\": {\"small\": \"[0 TO 1.0]\"," + "\"medium\": \"[1.1 TO 3.0]\", \"large\": \"[3.1 TO 9999999]\"} }").drillDown("class", "mammals").querySearchResult("class:mammal", Animal.class);
assertNotNull(rslt);
assertNotNull(rslt.getRanges());
assertEquals(1, rslt.getRanges().entrySet().size());
assertEquals(3, rslt.getRanges().get("min_length").entrySet().size());
assertEquals(new Long(0), rslt.getRanges().get("min_length").get("small"));
assertEquals(new Long(0), rslt.getRanges().get("min_length").get("medium"));
assertEquals(new Long(0), rslt.getRanges().get("min_length").get("large"));
}
use of com.cloudant.client.api.Search in project java-cloudant by cloudant.
the class SearchTests method groupSortTest.
@Test
public void groupSortTest() {
Search srch = db.search("views101/animals");
Map<String, List<Animal>> groups = srch.includeDocs(true).groupField("diet", false).groupSort("[\"-diet<string>\"]").queryGroups("l*", Animal.class);
assertNotNull(groups);
assertEquals(2, groups.size());
Iterator<String> it = groups.keySet().iterator();
// diet in reverse order
assertEquals("omnivore", it.next());
assertEquals("herbivore", it.next());
}
use of com.cloudant.client.api.Search in project java-cloudant by cloudant.
the class SearchTests method bookmarkTest.
@Test
public void bookmarkTest() {
Search srch = db.search("views101/animals");
SearchResult<Animal> rslt = srch.limit(4).querySearchResult("class:mammal", Animal.class);
Search srch1 = db.search("views101/animals");
srch1.bookmark(rslt.getBookmark()).querySearchResult("class:mammal", Animal.class);
}
Aggregations