use of org.apache.solr.search.QueryWrapperFilter in project lucene-solr by apache.
the class ExpandComponent method getGroupQuery.
private Query getGroupQuery(String fname, FieldType ft, int size, LongHashSet groupSet) {
BytesRef[] bytesRefs = new BytesRef[size];
BytesRefBuilder term = new BytesRefBuilder();
Iterator<LongCursor> it = groupSet.iterator();
int index = -1;
while (it.hasNext()) {
LongCursor cursor = it.next();
String stringVal = numericToString(ft, cursor.value);
ft.readableToIndexed(stringVal, term);
bytesRefs[++index] = term.toBytesRef();
}
return new SolrConstantScoreQuery(new QueryWrapperFilter(new TermInSetQuery(fname, bytesRefs)));
}
use of org.apache.solr.search.QueryWrapperFilter in project lucene-solr by apache.
the class ChildDocTransformer method create.
@Override
public DocTransformer create(String field, SolrParams params, SolrQueryRequest req) {
SchemaField uniqueKeyField = req.getSchema().getUniqueKeyField();
if (uniqueKeyField == null) {
throw new SolrException(ErrorCode.BAD_REQUEST, " ChildDocTransformer requires the schema to have a uniqueKeyField.");
}
String parentFilter = params.get("parentFilter");
if (parentFilter == null) {
throw new SolrException(ErrorCode.BAD_REQUEST, "Parent filter should be sent as parentFilter=filterCondition");
}
String childFilter = params.get("childFilter");
int limit = params.getInt("limit", 10);
BitSetProducer parentsFilter = null;
try {
Query parentFilterQuery = QParser.getParser(parentFilter, req).getQuery();
parentsFilter = new QueryBitSetProducer(new QueryWrapperFilter(parentFilterQuery));
} catch (SyntaxError syntaxError) {
throw new SolrException(ErrorCode.BAD_REQUEST, "Failed to create correct parent filter query");
}
Query childFilterQuery = null;
if (childFilter != null) {
try {
childFilterQuery = QParser.getParser(childFilter, req).getQuery();
} catch (SyntaxError syntaxError) {
throw new SolrException(ErrorCode.BAD_REQUEST, "Failed to create correct child filter query");
}
}
return new ChildDocTransformer(field, parentsFilter, uniqueKeyField, req.getSchema(), childFilterQuery, limit);
}
use of org.apache.solr.search.QueryWrapperFilter in project lucene-solr by apache.
the class ExpandComponent method getGroupQuery.
private Query getGroupQuery(String fname, int size, IntObjectHashMap<BytesRef> ordBytes) throws Exception {
BytesRef[] bytesRefs = new BytesRef[size];
int index = -1;
Iterator<IntObjectCursor<BytesRef>> it = ordBytes.iterator();
while (it.hasNext()) {
IntObjectCursor<BytesRef> cursor = it.next();
bytesRefs[++index] = cursor.value;
}
return new SolrConstantScoreQuery(new QueryWrapperFilter(new TermInSetQuery(fname, bytesRefs)));
}
use of org.apache.solr.search.QueryWrapperFilter in project lucene-solr by apache.
the class ExpandComponent method getPointGroupQuery.
private Query getPointGroupQuery(SchemaField sf, int size, LongHashSet groupSet) {
Iterator<LongCursor> it = groupSet.iterator();
List<String> values = new ArrayList<>(size);
FieldType ft = sf.getType();
while (it.hasNext()) {
LongCursor cursor = it.next();
values.add(numericToString(ft, cursor.value));
}
return new SolrConstantScoreQuery(new QueryWrapperFilter(sf.getType().getSetQuery(null, sf, values)));
}
use of org.apache.solr.search.QueryWrapperFilter in project lucene-solr by apache.
the class CurrencyValue method getRangeQuery.
public Query getRangeQuery(QParser parser, SchemaField field, final CurrencyValue p1, final CurrencyValue p2, final boolean minInclusive, final boolean maxInclusive) {
String currencyCode = (p1 != null) ? p1.getCurrencyCode() : (p2 != null) ? p2.getCurrencyCode() : defaultCurrency;
// ValueSourceRangeFilter doesn't check exists(), so we have to
final Filter docsWithValues = new QueryWrapperFilter(new FieldValueQuery(getAmountField(field).getName()));
final Filter vsRangeFilter = new ValueSourceRangeFilter(new RawCurrencyValueSource(field, currencyCode, parser), p1 == null ? null : p1.getAmount() + "", p2 == null ? null : p2.getAmount() + "", minInclusive, maxInclusive);
final BooleanQuery.Builder docsInRange = new BooleanQuery.Builder();
docsInRange.add(docsWithValues, Occur.FILTER);
docsInRange.add(vsRangeFilter, Occur.FILTER);
return new SolrConstantScoreQuery(new QueryWrapperFilter(docsInRange.build()));
}
Aggregations