use of org.apache.jackrabbit.oak.spi.query.IndexRow in project jackrabbit-oak by apache.
the class IndexPathServiceImpl method getIndexPaths.
@Override
public Iterable<String> getIndexPaths() {
NodeState nodeType = NodeStateUtils.getNode(nodeStore.getRoot(), "/oak:index/nodetype");
checkState("property".equals(nodeType.getString("type")), "nodetype index at " + "/oak:index/nodetype is found to be disabled. Cannot determine the paths of all indexes");
// Check if oak:QueryIndexDefinition is indexed as part of nodetype index
boolean indxDefnTypeIndexed = Iterables.contains(nodeType.getNames(DECLARING_NODE_TYPES), INDEX_DEFINITIONS_NODE_TYPE);
if (!indxDefnTypeIndexed) {
log.warn("{} is not found to be indexed as part of nodetype index. Non root indexes would " + "not be listed", INDEX_DEFINITIONS_NODE_TYPE);
NodeState oakIndex = nodeStore.getRoot().getChildNode("oak:index");
return transform(filter(oakIndex.getChildNodeEntries(), cne -> INDEX_DEFINITIONS_NODE_TYPE.equals(cne.getNodeState().getName(JCR_PRIMARYTYPE))), cne -> PathUtils.concat("/oak:index", cne.getName()));
}
return () -> {
Iterator<IndexRow> itr = getIndex().query(createFilter(INDEX_DEFINITIONS_NODE_TYPE), nodeStore.getRoot());
return transform(itr, input -> input.getPath());
};
}
use of org.apache.jackrabbit.oak.spi.query.IndexRow 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());
}
}
use of org.apache.jackrabbit.oak.spi.query.IndexRow in project jackrabbit-oak by apache.
the class LuceneIndexTest method testLuceneLazyCursor.
@Test
public void testLuceneLazyCursor() throws Exception {
NodeBuilder index = builder.child(INDEX_DEFINITIONS_NAME);
newLucenePropertyIndexDefinition(index, "lucene", ImmutableSet.of("foo"), null);
NodeState before = builder.getNodeState();
builder.setProperty("foo", "bar");
for (int i = 0; i < LuceneIndex.LUCENE_QUERY_BATCH_SIZE; i++) {
builder.child("parent").child("child" + i).setProperty("foo", "bar");
}
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_BASE);
filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
List<IndexPlan> plans = queryIndex.getPlans(filter, null, indexed);
Cursor cursor = queryIndex.query(plans.get(0), indexed);
List<String> paths = copyOf(transform(cursor, new Function<IndexRow, String>() {
public String apply(IndexRow input) {
return input.getPath();
}
}));
assertTrue(!paths.isEmpty());
assertEquals(LuceneIndex.LUCENE_QUERY_BATCH_SIZE + 1, paths.size());
}
Aggregations