LuceneSearch implements SearchService { @Override public void addIndexDoc(Note note) { try { addIndexDocAsync(note); writer.commit(); } catch (IOException e) { LOG.error("Failed to add note {} to index", note, e); } } LuceneSearch(); @Override List<Map<String, String>> query(String queryStr); @Override void updateIndexDoc(Note note); @Override void addIndexDocs(Collection<Note> collection); @Override void addIndexDoc(Note note); @Override void deleteIndexDocs(Note note); @Override void deleteIndexDoc(Note note, Paragraph p); @Override void close();  }
@Test public void indexKeyContract() throws IOException { Note note1 = newNoteWithParagraph("Notebook1", "test"); notebookIndex.addIndexDoc(note1); String id = resultForQuery("test").get(0).get(LuceneSearch.ID_FIELD); assertThat(Splitter.on("/").split(id)) .containsAllOf(note1.getId(), LuceneSearch.PARAGRAPH, note1.getLastParagraph().getId()); }