aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/schema/UnrankedRankProfile.java
blob: d49264eaac48881b618989ff5d88d644499ccd2d (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 Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema;

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(Schema schema, RankProfileRegistry rankProfileRegistry) {
        super("unranked", schema, rankProfileRegistry);
        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);
    }

}