Search in sources :

Example 11 with SelectorImpl

use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.

the class SolrQueryIndexTest method testNoPlanWithPropertyRestrictions.

@Test
public void testNoPlanWithPropertyRestrictions() throws Exception {
    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(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) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 12 with SelectorImpl

use of org.apache.jackrabbit.oak.query.ast.SelectorImpl 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());
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) NodeTypeInfo(org.apache.jackrabbit.oak.query.ast.NodeTypeInfo) SelectorImpl(org.apache.jackrabbit.oak.query.ast.SelectorImpl) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) NodeStateNodeTypeInfoProvider(org.apache.jackrabbit.oak.query.NodeStateNodeTypeInfoProvider) NodeTypeInfoProvider(org.apache.jackrabbit.oak.query.ast.NodeTypeInfoProvider) NodeStateNodeTypeInfoProvider(org.apache.jackrabbit.oak.query.NodeStateNodeTypeInfoProvider)

Example 13 with SelectorImpl

use of org.apache.jackrabbit.oak.query.ast.SelectorImpl 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)));
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) NodeTypeInfo(org.apache.jackrabbit.oak.query.ast.NodeTypeInfo) Filter(org.apache.jackrabbit.oak.spi.query.Filter) SelectorImpl(org.apache.jackrabbit.oak.query.ast.SelectorImpl) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) NodeStateNodeTypeInfoProvider(org.apache.jackrabbit.oak.query.NodeStateNodeTypeInfoProvider) NodeTypeInfoProvider(org.apache.jackrabbit.oak.query.ast.NodeTypeInfoProvider) NodeStateNodeTypeInfoProvider(org.apache.jackrabbit.oak.query.NodeStateNodeTypeInfoProvider)

Example 14 with SelectorImpl

use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.

the class SolrQueryIndexTest method testNoMoreThanThreeSolrRequests.

@Test
public void testNoMoreThanThreeSolrRequests() throws Exception {
    NodeState root = InitialContent.INITIAL_CONTENT;
    SelectorImpl selector = newSelector(root, "a");
    String sqlQuery = "select [jcr:path], [jcr:score] from [nt:base] as a where" + " contains([jcr:content/*], 'founded')";
    SolrClient solrServer = mock(SolrClient.class);
    SolrServerProvider solrServerProvider = mock(SolrServerProvider.class);
    when(solrServerProvider.getSearchingSolrServer()).thenReturn(solrServer);
    OakSolrConfigurationProvider configurationProvider = mock(OakSolrConfigurationProvider.class);
    OakSolrConfiguration configuration = new DefaultSolrConfiguration() {

        @Override
        public boolean useForPropertyRestrictions() {
            return true;
        }

        @Override
        public int getRows() {
            return 10;
        }
    };
    when(configurationProvider.getConfiguration()).thenReturn(configuration);
    SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, configurationProvider, solrServerProvider);
    FilterImpl filter = new FilterImpl(selector, sqlQuery, new QueryEngineSettings());
    CountingResponse response = new CountingResponse(0);
    when(solrServer.query(any(SolrParams.class))).thenReturn(response);
    List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, null, root);
    for (QueryIndex.IndexPlan p : plans) {
        Cursor cursor = solrQueryIndex.query(p, root);
        assertNotNull(cursor);
        while (cursor.hasNext()) {
            IndexRow row = cursor.next();
            assertNotNull(row);
        }
        assertEquals(3, response.getCounter());
    }
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) IndexRow(org.apache.jackrabbit.oak.spi.query.IndexRow) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) OakSolrConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration) Cursor(org.apache.jackrabbit.oak.spi.query.Cursor) OakSolrConfigurationProvider(org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider) SolrClient(org.apache.solr.client.solrj.SolrClient) SolrServerProvider(org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider) SelectorImpl(org.apache.jackrabbit.oak.query.ast.SelectorImpl) DefaultSolrConfiguration(org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfiguration) SolrParams(org.apache.solr.common.params.SolrParams) QueryIndex(org.apache.jackrabbit.oak.spi.query.QueryIndex) Test(org.junit.Test)

Example 15 with SelectorImpl

use of org.apache.jackrabbit.oak.query.ast.SelectorImpl in project jackrabbit-oak by apache.

the class HybridPropertyIndexLookupTest method createFilter.

private 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());
}
Also used : FilterImpl(org.apache.jackrabbit.oak.query.index.FilterImpl) NodeTypeInfo(org.apache.jackrabbit.oak.query.ast.NodeTypeInfo) SelectorImpl(org.apache.jackrabbit.oak.query.ast.SelectorImpl) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) NodeStateNodeTypeInfoProvider(org.apache.jackrabbit.oak.query.NodeStateNodeTypeInfoProvider) NodeTypeInfoProvider(org.apache.jackrabbit.oak.query.ast.NodeTypeInfoProvider) NodeStateNodeTypeInfoProvider(org.apache.jackrabbit.oak.query.NodeStateNodeTypeInfoProvider)

Aggregations

SelectorImpl (org.apache.jackrabbit.oak.query.ast.SelectorImpl)36 FilterImpl (org.apache.jackrabbit.oak.query.index.FilterImpl)30 QueryEngineSettings (org.apache.jackrabbit.oak.query.QueryEngineSettings)29 QueryIndex (org.apache.jackrabbit.oak.spi.query.QueryIndex)17 Test (org.junit.Test)17 LinkedList (java.util.LinkedList)14 NodeStateNodeTypeInfoProvider (org.apache.jackrabbit.oak.query.NodeStateNodeTypeInfoProvider)14 NodeTypeInfo (org.apache.jackrabbit.oak.query.ast.NodeTypeInfo)14 NodeTypeInfoProvider (org.apache.jackrabbit.oak.query.ast.NodeTypeInfoProvider)14 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)10 ColumnImpl (org.apache.jackrabbit.oak.query.ast.ColumnImpl)4 DefaultSolrConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfiguration)3 OakSolrConfiguration (org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration)3 OakSolrConfigurationProvider (org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider)3 SolrServerProvider (org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider)3 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)3 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 PropertyValue (org.apache.jackrabbit.oak.api.PropertyValue)1