public void testQueryStories() throws Exception { List<Story> stories = new ArrayList<Story>(); for (int i = 0; i < 5; i++) { Story story = createStory(i); stories.add(story); } stories.get(0).setAuthor("Andrew Fontaine"); stories.get(1).setTitle("Thanks Andrew"); stories.get(2).setSynopsis("How Andrew ruined civ."); for (Story s : stories) { boolean result = es.publishStory(s, null); assertTrue(es.getErrorMessage(), result); } // Give elasticsearch some time, it is having a mid life crisis // about if it wants to be a server anymore. Thread.sleep(4000); String filter = "Andrew Fontaine"; List<Story> result = es.queryStories(filter, 0, 10); for (Story s : stories) { try { es.deleteStory(s.getId()); } catch (Exception e) { // keep on trucking } } assertTrue(result.size() >= 3); assertTrue("Story missing from results", result.contains(stories.get(0))); assertTrue("Story missing from results", result.contains(stories.get(1))); assertTrue("Story missing from results", result.contains(stories.get(2))); for (Story s : result) { assertEquals(s.getId(), s.getThumbnail().getId()); assertNotNull(s.getThumbnail().getEncodedBitmap()); } }