@Test public void indexNoteNameUpdatedOnNoteSave() throws IOException { Note note1 = newNoteWithParagraph("Notebook1", "test"); Note note2 = newNoteWithParagraphs("Notebook2", "not test", "not test at all"); noteSearchService.addIndexDocs(Arrays.asList(note1, note2)); assertThat(resultForQuery("test").size()).isEqualTo(3); note1.setName("NotebookN"); note1.persist(anonymous); assertThat(resultForQuery("Notebook1")).isEmpty(); assertThat(resultForQuery("NotebookN")).isNotEmpty(); assertThat(resultForQuery("NotebookN").size()).isEqualTo(1); }
@Override public void addIndexDocs(Collection<Note> collection) { int docsIndexed = 0; long start = System.nanoTime(); try { for (Note note : collection) { addIndexDocAsync(note); docsIndexed++; } } catch (IOException e) { LOG.error("Failed to index all Notebooks", e); } finally { try { writer.commit(); } catch (IOException e) { LOG.error("Failed to save index", e); } long end = System.nanoTime(); LOG.info("Indexing {} notebooks took {}ms", docsIndexed, TimeUnit.NANOSECONDS.toMillis(end - start)); } }
LuceneSearch implements SearchService { @Override public void addIndexDocs(Collection<Note> collection) { int docsIndexed = 0; long start = System.nanoTime(); try { for (Note note : collection) { addIndexDocAsync(note); docsIndexed++; } } catch (IOException e) { LOG.error("Failed to index all Notebooks", e); } finally { try { writer.commit(); } catch (IOException e) { LOG.error("Failed to save index", e); } long end = System.nanoTime(); LOG.info("Indexing {} notebooks took {}ms", docsIndexed, TimeUnit.NANOSECONDS.toMillis(end - start)); } } }
LuceneSearch implements SearchService { @Override public void addIndexDocs(Collection<Note> collection) { int docsIndexed = 0; long start = System.nanoTime(); try { for (Note note : collection) { addIndexDocAsync(note); docsIndexed++; } } catch (IOException e) { LOG.error("Failed to index all Notebooks", e); } finally { try { writer.commit(); } catch (IOException e) { LOG.error("Failed to save index", e); } long end = System.nanoTime(); LOG.info("Indexing {} notebooks took {}ms", docsIndexed, TimeUnit.NANOSECONDS.toMillis(end - start)); } } LuceneSearch(); }
LuceneSearch implements SearchService { @Override public void addIndexDocs(Collection<Note> collection) { int docsIndexed = 0; long start = System.nanoTime(); try { for (Note note : collection) { addIndexDocAsync(note); docsIndexed++; } } catch (IOException e) { LOG.error("Failed to index all Notebooks", e); } finally { try { writer.commit(); } catch (IOException e) { LOG.error("Failed to save index", e); } long end = System.nanoTime(); LOG.info("Indexing {} notebooks took {}ms", docsIndexed, TimeUnit.NANOSECONDS.toMillis(end - start)); } } 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(); }
LuceneSearch implements SearchService { @Override public void addIndexDocs(Collection<Note> collection) { int docsIndexed = 0; long start = System.nanoTime(); try { for (Note note : collection) { addIndexDocAsync(note); docsIndexed++; } } catch (IOException e) { LOG.error("Failed to index all Notebooks", e); } finally { try { writer.commit(); } catch (IOException e) { LOG.error("Failed to save index", e); } long end = System.nanoTime(); LOG.info("Indexing {} notebooks took {}ms", docsIndexed, TimeUnit.NANOSECONDS.toMillis(end - start)); } } 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();  }