use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class OakSolrNodeStateConfigurationTest method setUp.
@Before
public void setUp() throws Exception {
store = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
NodeBuilder builder = store.getRoot().builder();
builder.setProperty("a", 1).setProperty("b", 2).setProperty("c", 3);
builder.setChildNode("x");
builder.setChildNode("y");
builder.setChildNode("z");
builder.setChildNode("oak:index").setChildNode("solrIdx").setProperty("type", "solr").setProperty("rows", "100");
store.merge(builder, EmptyHook.INSTANCE, CommitInfo.EMPTY);
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class SolrIndexLookupTest method collectPathOnSubNode.
@Test
public void collectPathOnSubNode() throws Exception {
NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
newSolrIndexDefinition(index, "l1", of("foo"));
index = builder.child("a").child(INDEX_DEFINITIONS_NAME);
newSolrIndexDefinition(index, "l2", of("foo"));
index = builder.child("a").child("b").child(INDEX_DEFINITIONS_NAME);
newSolrIndexDefinition(index, "l3", of("foo"));
SolrIndexLookup lookup = new SolrIndexLookup(builder.getNodeState());
FilterImpl f = FilterImpl.newTestInstance();
f.restrictPath("/a", Filter.PathRestriction.EXACT);
assertEquals(of("/oak:index/l1", "/a/oak:index/l2"), lookup.collectIndexNodePaths(f));
f.restrictPath("/a/b", Filter.PathRestriction.EXACT);
assertEquals(of("/oak:index/l1", "/a/oak:index/l2", "/a/b/oak:index/l3"), lookup.collectIndexNodePaths(f));
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class SolrIndexLookupTest method collectPathOnRootNode.
@Test
public void collectPathOnRootNode() throws Exception {
NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
newSolrIndexDefinition(index, "l1", of("foo"));
newSolrIndexDefinition(index, "l2", of("foo"));
SolrIndexLookup lookup = new SolrIndexLookup(builder.getNodeState());
FilterImpl f = FilterImpl.newTestInstance();
f.restrictPath("/", Filter.PathRestriction.EXACT);
assertEquals(of("/oak:index/l1", "/oak:index/l2"), lookup.collectIndexNodePaths(f));
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class SolrQueryIndexTest method testPlanWithPropertyRestrictionsEnabledAndUsedProperty.
@Test
public void testPlanWithPropertyRestrictionsEnabledAndUsedProperty() throws Exception {
NodeBuilder builder = nodeState.builder();
builder.child("oak:index").child("solr").setProperty("usedProperties", Collections.singleton("name"), Type.STRINGS).setProperty("propertyRestrictions", true);
nodeState = builder.getNodeState();
SelectorImpl selector = newSelector(nodeState, "a");
SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
FilterImpl filter = new FilterImpl(selector, "select * from [nt:base] as a where name = 'hello')", new QueryEngineSettings());
filter.restrictProperty("name", Operator.EQUAL, PropertyValues.newString("hello"));
List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
assertEquals(1, plans.size());
}
use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.
the class IndexPlannerTest method nullPropertyCheck2.
@Test
public void nullPropertyCheck2() throws Exception {
root = registerTestNodeType(builder).getNodeState();
NodeBuilder defn = newLucenePropertyIndexDefinition(builder, "test", of("foo"), "async");
NodeBuilder rules = defn.child(INDEX_RULES);
TestUtil.child(rules, "oak:TestNode/properties/prop2").setProperty(LuceneIndexConstants.PROP_NAME, "foo").setProperty(LuceneIndexConstants.PROP_NULL_CHECK_ENABLED, true).setProperty(LuceneIndexConstants.PROP_PROPERTY_INDEX, true);
IndexDefinition idxDefn = new IndexDefinition(root, builder.getNodeState().getChildNode("test"), "/foo");
IndexNode node = createIndexNode(idxDefn);
FilterImpl filter = createFilter(NT_TEST);
filter.restrictProperty("foo", Operator.EQUAL, null);
IndexPlanner planner = new IndexPlanner(node, "/foo", filter, Collections.<OrderEntry>emptyList());
QueryIndex.IndexPlan plan = planner.getPlan();
assertNotNull("For null checks plan should be returned with nullCheckEnabled", plan);
IndexPlanner.PlanResult pr = (IndexPlanner.PlanResult) plan.getAttribute(LucenePropertyIndex.ATTR_PLAN_RESULT);
assertNotNull(pr.getPropDefn(filter.getPropertyRestriction("foo")));
}
Aggregations