aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/grouping/request/SummaryValue.java
blob: 970207248fbbd9a341dee823c1cfe027830b8f97 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.grouping.request;

/**
 * This class represents a document summary in a {@link GroupingExpression}. It evaluates to the summary of the input
 * {@link com.yahoo.search.result.Hit} that corresponds to the named summary class.
 *
 * @author Simon Thoresen Hult
 */
public class SummaryValue extends DocumentValue {

    private final String name;

    /**
     * Constructs a new instance of this class, using the default summary class.
     */
    public SummaryValue() {
        this(null, null, null);
    }

    /**
     * Constructs a new instance of this class.
     *
     * @param summaryName The name of the summary class to assign to this.
     */
    public SummaryValue(String summaryName) {
        this(null, null, summaryName);
    }

    private SummaryValue(String label, Integer level, String summaryName) {
        super("summary(" + (summaryName == null ? "" : summaryName)  + ")", label, level);
        name = summaryName;
    }

    @Override
    public SummaryValue copy() {
        return new SummaryValue(getLabel(), getLevelOrNull(), getSummaryName());
    }

    /**
     * Returns the name of the summary class used to retrieve the hit from the search node.
     *
     * @return The summary name.
     */
    public String getSummaryName() {
        return name;
    }

}