Condition { public final Query query(Schema schema) { Query query = doQuery(schema); return boost == null ? query : new BoostQuery(query, boost); } Condition(Float boost); final Query query(Schema schema); abstract Set<String> postProcessingFields(); @Override String toString(); final Float boost; }
@Test public void testQueryWithBoost() { Condition condition = new MockCondition(0.7f); Schema schema = schema().build(); Query query = condition.query(schema); assertTrue("Query is not boosted", query instanceof BoostQuery); BoostQuery boostQuery = (BoostQuery) query; assertEquals("Query boost is wrong", 0.7f, boostQuery.getBoost(), 0); }
@Test public void testQueryWithoutBoost() { Condition condition = new MockCondition(null); Schema schema = schema().build(); Query query = condition.query(schema); assertEquals("Query type is wrong", MatchAllDocsQuery.class, query.getClass()); }