ElasticsearchSearcher { public SearchResponse search(String token) { return search(token, Collections.<String>emptyList()); } ElasticsearchSearcher(Client client); SearchResponse search(String token); List<Result> getResults(SearchResponse response); Faceting getFacets(SearchResponse response); SearchResponse search(String token, Collection<String> filterQueries);  }
@Test public void matchInTitleIsFound() throws IOException { indexExampleTalk(); assertEquals(1, search("test").size()); }
@Test public void phraseMatchInTitle() throws IOException { indexExampleTalk(); assertEquals(1, search("mit Elasticsearch").size()); }
@Test public void emptyQueryReturnsDocuments() throws IOException { indexExampleTalk(); assertEquals(1, search("").size()); }
@Test public void filtersAreApplied() throws IOException { indexExampleTalk(); SearchResponse response = searcher.search("", Arrays.asList("category:SomeCrazyStuff")); assertEquals(0, response.getHits().getTotalHits()); response = searcher.search("", Arrays.asList("category:" + talk.categories.get(0))); assertEquals(1, response.getHits().getTotalHits()); }
@Ignore("You can't search on an empty index") @Test public void zeroResultsOnEmptyIndex() { assertEquals(0, search("*:*").size()); }