use of com.cloudant.client.api.query.QueryBuilder in project java-cloudant by cloudant.
the class QueryTests method basicSelector14.
// "$type operator used with full text indexing"
@Test
public void basicSelector14() {
QueryBuilder qb = new QueryBuilder(type("year", Type.NUMBER));
Assertions.assertEquals("{\"selector\": {\"year\": {\"$type\": \"number\"}}}", qb.build());
}
use of com.cloudant.client.api.query.QueryBuilder in project java-cloudant by cloudant.
the class QueryTests method basicSelector16.
// "$nin operator used with full text indexing"
@Test
public void basicSelector16() {
QueryBuilder qb = new QueryBuilder(and(gt("year", 2009), nin("year", 2010, 2015)));
Assertions.assertEquals("{\"selector\": {\"$and\": [{\"year\": {\"$gt\": 2009}}, " + "{\"year\": {\"$nin\": [2010, 2015]}}]}}", qb.build());
}
use of com.cloudant.client.api.query.QueryBuilder in project java-cloudant by cloudant.
the class QueryTests method basicSelector1WithSort.
// "Selector basics"
@Test
public void basicSelector1WithSort() {
QueryBuilder qb = new QueryBuilder(eq("director", "Lars von Trier")).sort(Sort.asc("year"), Sort.desc("director"));
Assertions.assertEquals("{\"selector\": {\"director\": {\"$eq\": \"Lars von Trier\"}}, " + "\"sort\": [{\"year\": \"asc\"}, {\"director\": \"desc\"}]}", qb.build());
}
use of com.cloudant.client.api.query.QueryBuilder in project java-cloudant by cloudant.
the class QueryTests method complexSelector2.
@Test
public void complexSelector2() {
QueryBuilder qb = new QueryBuilder(or(and(eq("Actor", "Schwarzenegger"), eq("Year", 2012)), and(eq("Actor", "de Vito"), eq("Year", 2001))));
Assertions.assertEquals("{\"selector\": {\"$or\": [{\"$and\": [{\"Actor\": {\"$eq\": " + "\"Schwarzenegger\"}}, {\"Year\": {\"$eq\": 2012}}]}, {\"$and\": [{\"Actor\": " + "{\"$eq\": \"de Vito\"}}, {\"Year\": {\"$eq\": 2001}}]}]}}", qb.build());
}
use of com.cloudant.client.api.query.QueryBuilder in project java-cloudant by cloudant.
the class QueryTests method basicSelector8.
// "$not operator used with database indexed on the field "year""
@Test
public void basicSelector8() {
QueryBuilder qb = new QueryBuilder(and(gte("year", 1900), lte("year", 1903), not(eq("year", 1901))));
Assertions.assertEquals("{\"selector\": {\"$and\": [{\"year\": {\"$gte\": 1900}}, " + "{\"year\": {\"$lte\": 1903}}, {\"$not\": {\"year\": {\"$eq\": 1901}}}]}}", qb.build());
}
Aggregations