Search in sources :

Example 1 with SolrConstantScoreQuery

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

the class FilterQuery method createWeight.

@Override
public Weight createWeight(IndexSearcher searcher, boolean needScores, float boost) throws IOException {
    if (!(searcher instanceof SolrIndexSearcher)) {
        // delete-by-query won't have SolrIndexSearcher
        return new BoostQuery(new ConstantScoreQuery(q), 0).createWeight(searcher, needScores, 1f);
    }
    SolrIndexSearcher solrSearcher = (SolrIndexSearcher) searcher;
    DocSet docs = solrSearcher.getDocSet(q);
    return new BoostQuery(new SolrConstantScoreQuery(docs.getTopFilter()), 0).createWeight(searcher, needScores, 1f);
}
Also used : SolrConstantScoreQuery(org.apache.solr.search.SolrConstantScoreQuery) ConstantScoreQuery(org.apache.lucene.search.ConstantScoreQuery) SolrIndexSearcher(org.apache.solr.search.SolrIndexSearcher) SolrConstantScoreQuery(org.apache.solr.search.SolrConstantScoreQuery) BoostQuery(org.apache.lucene.search.BoostQuery) DocSet(org.apache.solr.search.DocSet)

Example 2 with SolrConstantScoreQuery

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

the class SolrQueryParserBase method handleBoost.

// Called from parser
// Raw queries are transformed to normal queries before wrapping in a BoostQuery
Query handleBoost(Query q, Token boost) {
    // q==null check is to avoid boosting null queries, such as those caused by stop words
    if (boost == null || boost.image.length() == 0 || q == null) {
        return q;
    }
    if (boost.image.charAt(0) == '=') {
        // syntax looks like foo:x^=3
        float val = Float.parseFloat(boost.image.substring(1));
        Query newQ = q;
        if (q instanceof ConstantScoreQuery || q instanceof SolrConstantScoreQuery) {
        // skip
        } else {
            newQ = new ConstantScoreQuery(rawToNormal(q));
        }
        return new BoostQuery(newQ, val);
    }
    float boostVal = Float.parseFloat(boost.image);
    return new BoostQuery(rawToNormal(q), boostVal);
}
Also used : Query(org.apache.lucene.search.Query) AutomatonQuery(org.apache.lucene.search.AutomatonQuery) SolrConstantScoreQuery(org.apache.solr.search.SolrConstantScoreQuery) PhraseQuery(org.apache.lucene.search.PhraseQuery) RegexpQuery(org.apache.lucene.search.RegexpQuery) MultiTermQuery(org.apache.lucene.search.MultiTermQuery) ConstantScoreQuery(org.apache.lucene.search.ConstantScoreQuery) MultiPhraseQuery(org.apache.lucene.search.MultiPhraseQuery) FuzzyQuery(org.apache.lucene.search.FuzzyQuery) MatchAllDocsQuery(org.apache.lucene.search.MatchAllDocsQuery) WildcardQuery(org.apache.lucene.search.WildcardQuery) FilterQuery(org.apache.solr.query.FilterQuery) BooleanQuery(org.apache.lucene.search.BooleanQuery) BoostQuery(org.apache.lucene.search.BoostQuery) SolrConstantScoreQuery(org.apache.solr.search.SolrConstantScoreQuery) ConstantScoreQuery(org.apache.lucene.search.ConstantScoreQuery) SolrConstantScoreQuery(org.apache.solr.search.SolrConstantScoreQuery) BoostQuery(org.apache.lucene.search.BoostQuery)

Example 3 with SolrConstantScoreQuery

use of org.apache.solr.search.SolrConstantScoreQuery 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)));
}
Also used : BytesRefBuilder(org.apache.lucene.util.BytesRefBuilder) LongCursor(com.carrotsearch.hppc.cursors.LongCursor) TermInSetQuery(org.apache.lucene.search.TermInSetQuery) SolrConstantScoreQuery(org.apache.solr.search.SolrConstantScoreQuery) QueryWrapperFilter(org.apache.solr.search.QueryWrapperFilter) BytesRef(org.apache.lucene.util.BytesRef)

Example 4 with SolrConstantScoreQuery

use of org.apache.solr.search.SolrConstantScoreQuery 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)));
}
Also used : IntObjectCursor(com.carrotsearch.hppc.cursors.IntObjectCursor) TermInSetQuery(org.apache.lucene.search.TermInSetQuery) SolrConstantScoreQuery(org.apache.solr.search.SolrConstantScoreQuery) QueryWrapperFilter(org.apache.solr.search.QueryWrapperFilter) BytesRef(org.apache.lucene.util.BytesRef)

Example 5 with SolrConstantScoreQuery

use of org.apache.solr.search.SolrConstantScoreQuery 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)));
}
Also used : LongCursor(com.carrotsearch.hppc.cursors.LongCursor) ArrayList(java.util.ArrayList) SolrConstantScoreQuery(org.apache.solr.search.SolrConstantScoreQuery) QueryWrapperFilter(org.apache.solr.search.QueryWrapperFilter) FieldType(org.apache.solr.schema.FieldType)

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