LuceneIndexPropertyQuery implements PropertyQuery { @Override public Iterable<String> getIndexedPaths(String propertyRelativePath, String value) { List<String> indexPaths = new ArrayList<>(2); LuceneIndexNode indexNode = tracker.acquireIndexNode(indexPath); if (indexNode != null) { try { TermQuery query = new TermQuery(new Term(propertyRelativePath, value)); TopDocs docs = indexNode.getSearcher().search(query, 10); IndexReader reader = indexNode.getSearcher().getIndexReader(); for (ScoreDoc d : docs.scoreDocs) { PathStoredFieldVisitor visitor = new PathStoredFieldVisitor(); reader.document(d.doc, visitor); indexPaths.add(visitor.getPath()); } } catch (IOException e) { log.warn("Error occurred while checking index {} for unique value " + "[{}] for [{}]", indexPath,value, propertyRelativePath, e); } finally { indexNode.release(); } } return indexPaths; } LuceneIndexPropertyQuery(IndexTracker tracker, String indexPath); @Override Iterable<String> getIndexedPaths(String propertyRelativePath, String value);  }
@Test public void simplePropertyIndex() throws Exception{ defnb.noAsync(); defnb.indexRule("nt:base").property("foo").propertyIndex(); assertEquals(0,Iterables.size(query.getIndexedPaths("foo", "bar"))); NodeState before = builder.getNodeState(); builder.child("a").setProperty("foo", "bar"); builder.child("b").setProperty("foo", "bar"); NodeState after = builder.getNodeState(); EditorHook hook = new EditorHook(new IndexUpdateProvider(new LuceneIndexEditorProvider())); NodeState indexed = hook.processCommit(before, after, CommitInfo.EMPTY); tracker.update(indexed); assertThat(query.getIndexedPaths("foo", "bar"), containsInAnyOrder("/a", "/b")); }