use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class SolrQueryIndexTest method testUnion.
@Test
public void testUnion() throws Exception {
SelectorImpl selector = mock(SelectorImpl.class);
SolrQueryIndex solrQueryIndex = new SolrQueryIndex(null, null, null);
String sqlQuery = "select [jcr:path], [jcr:score], [rep:excerpt] from [nt:hierarchyNode] as a where" + " isdescendantnode(a, '/content') and contains([jcr:content/*], 'founded') union select [jcr:path]," + " [jcr:score], [rep:excerpt] from [nt:hierarchyNode] as a where isdescendantnode(a, '/content') and " + "contains([jcr:content/jcr:title], 'founded') union select [jcr:path], [jcr:score], [rep:excerpt]" + " from [nt:hierarchyNode] as a where isdescendantnode(a, '/content') and " + "contains([jcr:content/jcr:description], 'founded') order by [jcr:score] desc";
FilterImpl filter = new FilterImpl(selector, sqlQuery, new QueryEngineSettings());
List<QueryIndex.OrderEntry> sortOrder = new LinkedList<QueryIndex.OrderEntry>();
List<QueryIndex.IndexPlan> plans = solrQueryIndex.getPlans(filter, sortOrder, nodeState);
assertEquals(0, plans.size());
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl 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());
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class LuceneIndexTest method createTestFilter.
private FilterImpl createTestFilter() {
FilterImpl filter = createFilter(NT_BASE);
filter.restrictProperty("foo", Operator.EQUAL, PropertyValues.newString("bar"));
return filter;
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class SelectorImpl method createFilter.
/**
* Create the filter condition for planning or execution.
*
* @param preparing whether a filter for the prepare phase should be made
* @return the filter
*/
@Override
public FilterImpl createFilter(boolean preparing) {
FilterImpl f = new FilterImpl(this, query.getStatement(), query.getSettings());
f.setPreparing(preparing);
if (joinCondition != null) {
joinCondition.restrict(f);
}
// we will need the excerpt
for (ColumnImpl c : query.getColumns()) {
if (c.getSelector().equals(this)) {
String columnName = c.getColumnName();
if (columnName.equals(QueryImpl.REP_EXCERPT) || columnName.equals(QueryImpl.OAK_SCORE_EXPLANATION)) {
f.restrictProperty(columnName, Operator.NOT_EQUAL, null);
} else if (columnName.startsWith(QueryImpl.REP_FACET)) {
f.restrictProperty(QueryImpl.REP_FACET, Operator.EQUAL, PropertyValues.newString(columnName));
}
}
}
// (".. is null" must be written as "not .. is not null").
if (queryConstraint != null) {
queryConstraint.restrict(f);
FullTextExpression ft = queryConstraint.getFullTextConstraint(this);
f.setFullTextConstraint(ft);
}
for (ConstraintImpl constraint : selectorConstraints) {
constraint.restrict(f);
}
return f;
}
use of org.apache.jackrabbit.oak.query.index.FilterImpl in project jackrabbit-oak by apache.
the class AggregateIndex method newAggregationFilter.
private static Filter newAggregationFilter(Filter filter, FullTextExpression exp) {
FilterImpl f = new FilterImpl(filter);
// disables node type checks for now
f.setMatchesAllTypes(true);
if (exp != null) {
f.setFullTextConstraint(exp);
}
return f;
}
Aggregations