Search in sources :

Example 6 with SolrConstantScoreQuery

use of org.apache.solr.search.SolrConstantScoreQuery 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()));
}
Also used : BooleanQuery(org.apache.lucene.search.BooleanQuery) ValueSourceRangeFilter(org.apache.solr.search.function.ValueSourceRangeFilter) ValueSourceRangeFilter(org.apache.solr.search.function.ValueSourceRangeFilter) QueryWrapperFilter(org.apache.solr.search.QueryWrapperFilter) Filter(org.apache.solr.search.Filter) FieldValueQuery(org.apache.lucene.search.FieldValueQuery) QueryWrapperFilter(org.apache.solr.search.QueryWrapperFilter) SolrConstantScoreQuery(org.apache.solr.search.SolrConstantScoreQuery)

Example 7 with SolrConstantScoreQuery

use of org.apache.solr.search.SolrConstantScoreQuery in project lucene-solr by apache.

the class BlockJoinParentQParser method parse.

@Override
public Query parse() throws SyntaxError {
    String filter = localParams.get(getParentFilterLocalParamName());
    String scoreMode = localParams.get("score", ScoreMode.None.name());
    QParser parentParser = subQuery(filter, null);
    Query parentQ = parentParser.getQuery();
    String queryText = localParams.get(QueryParsing.V);
    // there is no child query, return parent filter from cache
    if (queryText == null || queryText.length() == 0) {
        SolrConstantScoreQuery wrapped = new SolrConstantScoreQuery(getFilter(parentQ));
        wrapped.setCache(false);
        return wrapped;
    }
    QParser childrenParser = subQuery(queryText, null);
    Query childrenQuery = childrenParser.getQuery();
    return createQuery(parentQ, childrenQuery, scoreMode);
}
Also used : Query(org.apache.lucene.search.Query) SolrConstantScoreQuery(org.apache.solr.search.SolrConstantScoreQuery) ToParentBlockJoinQuery(org.apache.lucene.search.join.ToParentBlockJoinQuery) QParser(org.apache.solr.search.QParser) SolrConstantScoreQuery(org.apache.solr.search.SolrConstantScoreQuery)

Aggregations

SolrConstantScoreQuery (org.apache.solr.search.SolrConstantScoreQuery)7 QueryWrapperFilter (org.apache.solr.search.QueryWrapperFilter)4 LongCursor (com.carrotsearch.hppc.cursors.LongCursor)2 BooleanQuery (org.apache.lucene.search.BooleanQuery)2 BoostQuery (org.apache.lucene.search.BoostQuery)2 ConstantScoreQuery (org.apache.lucene.search.ConstantScoreQuery)2 Query (org.apache.lucene.search.Query)2 TermInSetQuery (org.apache.lucene.search.TermInSetQuery)2 BytesRef (org.apache.lucene.util.BytesRef)2 IntObjectCursor (com.carrotsearch.hppc.cursors.IntObjectCursor)1 ArrayList (java.util.ArrayList)1 AutomatonQuery (org.apache.lucene.search.AutomatonQuery)1 FieldValueQuery (org.apache.lucene.search.FieldValueQuery)1 FuzzyQuery (org.apache.lucene.search.FuzzyQuery)1 MatchAllDocsQuery (org.apache.lucene.search.MatchAllDocsQuery)1 MultiPhraseQuery (org.apache.lucene.search.MultiPhraseQuery)1 MultiTermQuery (org.apache.lucene.search.MultiTermQuery)1 PhraseQuery (org.apache.lucene.search.PhraseQuery)1 RegexpQuery (org.apache.lucene.search.RegexpQuery)1 WildcardQuery (org.apache.lucene.search.WildcardQuery)1