aboutsummaryrefslogtreecommitdiffstats
path: root/client/src/main/java/ai/vespa/client/dsl/G.java
blob: 8174bbf0f53cab4ad15349cf18177c154639b6e6 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.client.dsl;

/**
 * Helper class for generating group syntax
 * https://docs.vespa.ai/en/reference/grouping-syntax.html
 *
 * basically the syntax is exactly the same as Vespa group syntax.
 * The only exception "max" in the Vespa group syntax which represents 'max returned documents',
 * is replaced by "maxRtn" in the dsl lib.
 */
public class G {

    private G() { }

    public static Group all(IGroupOperation... ops) {
        return new Group("all", ops);
    }

    public static Group each(IGroupOperation... ops) {
        return new Group("each", ops);
    }

    public static GroupOperation group(String expr) {
        return new GroupOperation("group", expr);
    }

    public static GroupOperation maxRtn(int max) {
        return new GroupOperation("max", max);
    }

    public static GroupOperation order(String expr) {
        return new GroupOperation("order", expr);
    }

    public static GroupOperation output(Aggregator... aggrs) {
        return new GroupOperation("output", aggrs);
    }

    public static Aggregator max(int max) {
        return new Aggregator("max", max);
    }

    public static Aggregator summary() {
        return new Aggregator("summary");
    }

    public static Aggregator count() {
        return new Aggregator("count");
    }

    public static Aggregator summary(String summaryClass) {
        return new Aggregator("summary", summaryClass);
    }

}