示例#1
0
  @Test
  public void QueryElement() throws Exception {
    Query query1 = serializer.toQuery(author.like("Michael"), metadata);
    Query query2 = serializer.toQuery(text.like("Text"), metadata);

    BooleanExpression query = Expressions.anyOf(new QueryElement(query1), new QueryElement(query2));
    testQuery(query, "author:michael text:text", 1);
  }
示例#2
0
 private void testQuery(Expression<?> expr, String expectedQuery, int expectedHits)
     throws Exception {
   Query query = serializer.toQuery(expr, metadata);
   TopDocs docs = searcher.search(query, 100);
   assertEquals(expectedHits, docs.totalHits);
   assertEquals(expectedQuery, query.toString());
 }