use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class NodeTypeIndexTest method createFilter.
private static FilterImpl createFilter(NodeState root, String nodeTypeName) {
NodeTypeInfoProvider nodeTypes = new NodeStateNodeTypeInfoProvider(root);
NodeTypeInfo type = nodeTypes.getNodeTypeInfo(nodeTypeName);
SelectorImpl selector = new SelectorImpl(type, nodeTypeName);
return new FilterImpl(selector, "SELECT * FROM [" + nodeTypeName + "]", new QueryEngineSettings());
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class IndexUpdateTest method find.
private Set<String> find(PropertyIndexLookup lookup, String name, String value) {
NodeTypeInfoProvider nodeTypes = new NodeStateNodeTypeInfoProvider(root);
NodeTypeInfo type = nodeTypes.getNodeTypeInfo(NT_BASE);
SelectorImpl selector = new SelectorImpl(type, NT_BASE);
Filter filter = new FilterImpl(selector, "SELECT * FROM [nt:base]", new QueryEngineSettings());
return Sets.newHashSet(lookup.query(filter, name, PropertyValues.newString(value)));
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class DiffCollectorTest method testUUIDInner.
@Test
public void testUUIDInner() throws Exception {
NodeState root = EMPTY_NODE;
NodeBuilder builder = root.builder();
builder.child("a").setProperty("jcr:uuid", "abc");
NodeState before = builder.getNodeState();
builder = before.builder();
builder.child("a").child("b").setProperty("jcr:uuid", "xyz");
NodeState after = builder.getNodeState();
UUIDDiffCollector collector = new UUIDDiffCollector(before, after);
FilterImpl f = FilterImpl.newTestInstance();
f.restrictProperty("jcr:uuid", Operator.EQUAL, PropertyValues.newString("xyz"));
Set<String> result = collector.getResults(f);
Iterator<String> iterator = result.iterator();
assertTrue(iterator.hasNext());
assertEquals("a/b", iterator.next());
assertFalse(iterator.hasNext());
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class DiffCollectorTest method testUUID.
@Test
public void testUUID() throws Exception {
NodeState root = EMPTY_NODE;
NodeBuilder builder = root.builder();
builder.child("a").setProperty("jcr:uuid", "abc");
builder.child("b").setProperty("jcr:uuid", "xyz");
NodeState after = builder.getNodeState();
UUIDDiffCollector collector = new UUIDDiffCollector(root, after);
FilterImpl f = FilterImpl.newTestInstance();
f.restrictProperty("jcr:uuid", Operator.EQUAL, PropertyValues.newString("abc"));
Set<String> result = collector.getResults(f);
Iterator<String> iterator = result.iterator();
assertTrue(iterator.hasNext());
assertEquals("a", iterator.next());
assertFalse(iterator.hasNext());
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class LuceneIndexTest method testPropertyExistence.
@Test
public void testPropertyExistence() throws Exception {
root = TestUtil.registerTestNodeType(builder).getNodeState();
NodeBuilder index = newLucenePropertyIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "lucene", ImmutableSet.of("foo"), null);
NodeBuilder rules = index.child(INDEX_RULES);
NodeBuilder propNode = rules.child(NT_TEST).child(LuceneIndexConstants.PROP_NODE);
NodeBuilder fooProp = propNode.child("foo");
fooProp.setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true);
fooProp.setProperty(LuceneIndexConstants.PROP_NOT_NULL_CHECK_ENABLED, true);
NodeState before = builder.getNodeState();
createNodeWithType(builder, "a", NT_TEST).setProperty("foo", "bar");
createNodeWithType(builder, "b", NT_TEST).setProperty("foo", "bar");
createNodeWithType(builder, "c", NT_TEST);
NodeState after = builder.getNodeState();
NodeState indexed = HOOK.processCommit(before, after, CommitInfo.EMPTY);
tracker = new IndexTracker();
tracker.update(indexed);
AdvancedQueryIndex queryIndex = new LucenePropertyIndex(tracker);
FilterImpl filter = createFilter(NT_TEST);
filter.restrictProperty("foo", Operator.NOT_EQUAL, null);
assertFilter(filter, queryIndex, indexed, ImmutableList.of("/a", "/b"));
}
Aggregations