Search in sources :

Example 66 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class SolrQueryIndexTest method testNoPlanWithOnlyPrimaryTypeRestrictionsEnabled.

@Test
public void testNoPlanWithOnlyPrimaryTypeRestrictionsEnabled() throws Exception {
    NodeBuilder builder = nodeState.builder();
    builder.child("oak:index").child("solr").setProperty("primaryTypes", 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 jcr:primaryType = 'nt:unstructured')", new QueryEngineSettings());
    filter.restrictProperty("jcr:primaryType", Operator.EQUAL, PropertyValues.newString("nt:unstructured"));
    List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
    List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
    assertEquals(0, plans.size());
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) SelectorImpl(org.apache.jackrabbit.oak.query.ast.SelectorImpl) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) QueryIndex(org.apache.jackrabbit.oak.spi.query.QueryIndex) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 67 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class SolrQueryIndexTest method testNoPlanWithPropertyNotListedInUsedProperties.

@Test
public void testNoPlanWithPropertyNotListedInUsedProperties() 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 foo = 'bar')", new QueryEngineSettings());
    filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
    List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
    List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
    assertEquals(0, plans.size());
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) SelectorImpl(org.apache.jackrabbit.oak.query.ast.SelectorImpl) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) QueryIndex(org.apache.jackrabbit.oak.spi.query.QueryIndex) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 68 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class SolrQueryIndexTest method setUp.

@Before
public void setUp() throws Exception {
    NodeState root = EMPTY_NODE;
    NodeBuilder builder = root.builder();
    builder.child("oak:index").child("solr").setProperty(JCR_PRIMARYTYPE, "oak:QueryIndexDefinition").setProperty("type", "solr").child("server").setProperty("solrServerType", "embedded");
    nodeState = builder.getNodeState();
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Before(org.junit.Before)

Example 69 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class SolrQueryIndexTest method testPlanWithPropertyAndPrimaryTypeRestrictionsEnabled.

@Test
public void testPlanWithPropertyAndPrimaryTypeRestrictionsEnabled() throws Exception {
    NodeBuilder builder = nodeState.builder();
    builder.child("oak:index").child("solr").setProperty("propertyRestrictions", true).setProperty("primaryTypes", 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 jcr:primaryType = 'nt:unstructured')", new QueryEngineSettings());
    filter.restrictProperty("jcr:primaryType", Operator.EQUAL, PropertyValues.newString("nt:unstructured"));
    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());
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) SelectorImpl(org.apache.jackrabbit.oak.query.ast.SelectorImpl) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) QueryIndex(org.apache.jackrabbit.oak.spi.query.QueryIndex) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 70 with NodeBuilder

use of org.apache.jackrabbit.oak.spi.state.NodeBuilder in project jackrabbit-oak by apache.

the class SolrQueryIndexTest method testNoPlanWithPropertyRestrictionsEnabledButPropertyIgnored.

@Test
public void testNoPlanWithPropertyRestrictionsEnabledButPropertyIgnored() throws Exception {
    NodeBuilder builder = nodeState.builder();
    builder.child("oak:index").child("solr").setProperty("ignoredProperties", 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);
    // there's no plan matching the filter
    assertEquals(0, plans.size());
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) SelectorImpl(org.apache.jackrabbit.oak.query.ast.SelectorImpl) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) QueryIndex(org.apache.jackrabbit.oak.spi.query.QueryIndex) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)1190 Test (org.junit.Test)849 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)338 MemoryDocumentStore (org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore)96 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)82 LuceneIndexHelper.newLuceneIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLuceneIndexDefinition)80 LuceneIndexHelper.newLucenePropertyIndexDefinition (org.apache.jackrabbit.oak.plugins.index.lucene.util.LuceneIndexHelper.newLucenePropertyIndexDefinition)77 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)75 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)73 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)69 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)64 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)61 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)43 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)40 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)38 Blob (org.apache.jackrabbit.oak.api.Blob)36 ArrayList (java.util.ArrayList)29 CommitInfo (org.apache.jackrabbit.oak.spi.commit.CommitInfo)29 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)28 Nonnull (javax.annotation.Nonnull)26