@Test public void QueryElement() throws Exception { Query query1 = serializer.toQuery(author.like("Michael"), metadata); Query query2 = serializer.toQuery(text.like("Text"), metadata); BooleanExpression query = BooleanExpression.anyOf(new QueryElement(query1), new QueryElement(query2)); testQuery(query, "author:michael text:text", 1); }
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()); }