use of org.apache.solr.search.PostFilter in project SearchServices by Alfresco.
the class PostFilterQuery method getPostFilters.
private void getPostFilters(Query q, List<PostFilter> postFilters) {
if (q instanceof BooleanQuery) {
BooleanQuery bq = (BooleanQuery) q;
List<BooleanClause> clauses = bq.clauses();
for (BooleanClause clause : clauses) {
Query q1 = clause.getQuery();
getPostFilters(q1, postFilters);
}
} else if (q instanceof ContextAwareQuery) {
ContextAwareQuery cq = (ContextAwareQuery) q;
getPostFilters(cq.getLuceneQuery(), postFilters);
} else if (q instanceof PostFilter) {
postFilters.add((PostFilter) q);
} else if (q instanceof BoostQuery) {
BoostQuery bq = (BoostQuery) q;
getPostFilters(bq.getQuery(), postFilters);
}
}
use of org.apache.solr.search.PostFilter in project SearchServices by Alfresco.
the class PostFilterQuery method getFilterCollector.
public DelegatingCollector getFilterCollector(IndexSearcher searcher) {
List<PostFilter> postFilters = new ArrayList<PostFilter>();
getPostFilters(query, postFilters);
Collections.sort(postFilters, new PostFilterComp());
List<DelegatingCollector> delegatingCollectors = new ArrayList<DelegatingCollector>();
for (PostFilter postFilter : postFilters) {
DelegatingCollector delegatingCollector = postFilter.getFilterCollector(searcher);
if (!(delegatingCollector instanceof AllAccessCollector)) {
delegatingCollectors.add(delegatingCollector);
}
}
if (delegatingCollectors.size() == 0) {
return new AllAccessCollector();
} else if (delegatingCollectors.size() == 1) {
return delegatingCollectors.get(0);
} else {
return new WrapperCollector(delegatingCollectors);
}
}
Aggregations