summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/searchdefinition/UnrankedRankProfile.java
blob: bea0e70124dec3dbfc57032f2ed458c895e62e81 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition;

import com.yahoo.searchlib.rankingexpression.RankingExpression;
import com.yahoo.searchlib.rankingexpression.parser.ParseException;

/**
 * A low-cost ranking profile to use for watcher queries etc.
 *
 * @author Vegard Havdal
 */
public class UnrankedRankProfile extends RankProfile {

    public UnrankedRankProfile(Search search, RankProfileRegistry rankProfileRegistry, RankingConstants rankingConstants) {
        super("unranked", search, rankProfileRegistry, rankingConstants);
        try {
            RankingExpression exp = new RankingExpression("value(0)");
            this.setFirstPhaseRanking(exp);
        } catch (ParseException e) {
            throw new IllegalArgumentException("Could not parse the ranking expression 'value(0)' when setting up " +
                                               "the 'unranked' rank profile");
        }
        this.setIgnoreDefaultRankFeatures(true);
        this.setKeepRankCount(0);
        this.setRerankCount(0);
    }

}