@Test public void testQueryEmpty() { Schema schema = schema().build(); BooleanCondition condition = bool().boost(0.4).build(); BooleanQuery query = (BooleanQuery) condition.query(schema); assertEquals(0, query.getClauses().length); assertEquals(0.4f, query.getBoost(), 0f); }
@Test public void testQueryPureNot() { Schema schema = schema().mapper("name", stringMapper()).build(); BooleanCondition condition = bool().not(match("name", "jonathan")).boost(0.4).build(); BooleanQuery query = (BooleanQuery) condition.query(schema); assertEquals(2, query.getClauses().length); assertEquals(0.4f, query.getBoost(), 0f); }
@Test public void testQuery() { Schema schema = schema() .mapper("name", stringMapper()) .mapper("color", stringMapper()) .mapper("country", stringMapper()) .mapper("age", integerMapper()) .defaultAnalyzer("default") .build(); BooleanCondition condition = bool() .must(match("name", "jonathan"), range("age").lower(18).includeLower(true)) .should(match("color", "green"), match("color", "blue")) .not(match("country", "england")) .boost(0.4f) .build(); BooleanQuery query = (BooleanQuery) condition.query(schema); assertEquals(5, query.getClauses().length); assertEquals(0.4f, query.getBoost(), 0f); }