LuceneIndexer implements NodeStateIndexer { @Override public boolean index(NodeStateEntry entry) throws IOException, CommitFailedException { if (getFilterResult(entry.getPath()) != PathFilter.Result.INCLUDE) { return false; } IndexDefinition.IndexingRule indexingRule = definition.getApplicableIndexingRule(entry.getNodeState()); if (indexingRule == null) { return false; } LuceneDocumentMaker maker = newDocumentMaker(indexingRule, entry.getPath()); Document doc = maker.makeDocument(entry.getNodeState()); if (doc != null) { writeToIndex(doc, entry.getPath()); progressReporter.indexUpdate(definition.getIndexPath()); return true; } return false; } LuceneIndexer(IndexDefinition definition, LuceneIndexWriter indexWriter,
                         NodeBuilder builder, FulltextBinaryTextExtractor binaryTextExtractor,
                         IndexingProgressReporter progressReporter); @Override boolean shouldInclude(String path); @Override boolean shouldInclude(NodeDocument doc); @Override boolean index(NodeStateEntry entry); @Override boolean indexesRelativeNodes(); @Override Set<String> getRelativeIndexedNodeNames(); @Override void close();  }
@Test public void nodeIndexed_WithIncludedPaths() throws Exception{ LuceneIndexDefinitionBuilder idxb = new LuceneIndexDefinitionBuilder(); idxb.indexRule("nt:base").property("foo").propertyIndex(); idxb.includedPaths("/content"); NodeState defn = idxb.build(); IndexDefinition idxDefn = new IndexDefinition(root, defn, "/oak:index/testIndex"); NodeBuilder builder = root.builder(); LuceneIndexer indexer = new LuceneIndexer(idxDefn, mock(LuceneIndexWriter.class), builder, mock(FulltextBinaryTextExtractor.class), mock(IndexingProgressReporter.class)); NodeState testNode = EMPTY_NODE.builder().setProperty("foo","bar").getNodeState(); assertTrue(indexer.index(new NodeStateEntry(testNode, "/content/x"))); assertFalse(indexer.index(new NodeStateEntry(testNode, "/x"))); assertFalse(indexer.index(new NodeStateEntry(testNode, "/"))); }