HybridPropertyIndexLookup { public Iterable<String> query(Filter filter, String propertyName, Filter.PropertyRestriction restriction) { Set<String> values = ValuePatternUtil.getAllValues(restriction); Set<String> encodedValues = PropertyIndexUtil.encode(values); return query(filter, propertyName, encodedValues); } HybridPropertyIndexLookup(String indexPath, NodeState indexState);  HybridPropertyIndexLookup(String indexPath, NodeState indexState,
                                     String pathPrefix, boolean prependPathPrefix); Iterable<String> query(Filter filter, String propertyName, Filter.PropertyRestriction restriction); Iterable<String> query(Filter filter, String propertyName, PropertyValue value);  }
@Test public void simplePropertyRestriction() throws Exception{ defnb.indexRule("nt:base").property("foo").sync(); propertyUpdated("/a", "foo", "bar"); FilterImpl f = createFilter(); f.restrictProperty("foo", Operator.EQUAL, newString("bar")); assertThat(query(f, "foo"), containsInAnyOrder("/a")); }
@Test public void valuePattern() throws Exception{ defnb.indexRule("nt:base").property("foo").sync().valuePattern("(a.*|b)"); propertyUpdated("/a", "foo", "a"); propertyUpdated("/a1", "foo", "a1"); propertyUpdated("/b", "foo", "b"); propertyUpdated("/c", "foo", "c"); assertThat(query("foo", "a"), containsInAnyOrder("/a")); assertThat(query("foo", "a1"), containsInAnyOrder("/a1")); assertThat(query("foo", "b"), containsInAnyOrder("/b")); assertThat(query("foo", "c"), empty()); }
@Test public void relativeProperty() throws Exception{ defnb.indexRule("nt:base").property("foo").sync(); propertyUpdated("/a", "foo", "bar"); FilterImpl f = createFilter(); f.restrictProperty("jcr:content/foo", Operator.EQUAL, newString("bar")); assertThat(query(f, "foo", "jcr:content/foo"), containsInAnyOrder("/a")); }
@Test public void pathResultAbsolutePath() throws Exception{ defnb.indexRule("nt:base").property("foo").sync(); propertyUpdated("/a", "foo", "bar"); String propertyName = "foo"; FilterImpl filter = createFilter(); filter.restrictProperty("foo", Operator.EQUAL, newString("bar")); HybridPropertyIndexLookup lookup = new HybridPropertyIndexLookup(indexPath, builder.getNodeState()); Iterable<String> paths = lookup.query(filter, propertyName, filter.getPropertyRestriction(propertyName)); assertThat(ImmutableList.copyOf(paths), containsInAnyOrder("/a")); }
@Test public void nonRootIndex() throws Exception{ defnb.indexRule("nt:base").property("foo").sync(); indexPath = "/content/oak:index/fooIndex"; propertyUpdated("/a", "foo", "bar"); String propertyName = "foo"; FilterImpl filter = createFilter(); filter.restrictProperty("foo", Operator.EQUAL, newString("bar")); filter.restrictPath("/content", Filter.PathRestriction.ALL_CHILDREN); HybridPropertyIndexLookup lookup = new HybridPropertyIndexLookup(indexPath, builder.getNodeState(), "/content", false); Iterable<String> paths = lookup.query(filter, propertyName, filter.getPropertyRestriction(propertyName)); assertThat(ImmutableList.copyOf(paths), containsInAnyOrder("/a")); lookup = new HybridPropertyIndexLookup(indexPath, builder.getNodeState(), "/content", true); paths = lookup.query(filter, propertyName, filter.getPropertyRestriction(propertyName)); assertThat(ImmutableList.copyOf(paths), containsInAnyOrder("/content/a")); }