blob: eb336e1fc72359563bdaeececa6f5025a340de9d (
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
57
58
59
60
61
62
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.schema.derived;
import com.yahoo.schema.Schema;
import com.yahoo.vespa.documentmodel.SummaryField;
import com.yahoo.vespa.documentmodel.SummaryTransform;
import com.yahoo.vespa.config.search.summary.JuniperrcConfig;
import java.util.Set;
/**
* Generated juniperrc-config for controlling juniper.
*
* @author Simon Thoresen Hult
*/
public class Juniperrc extends Derived implements JuniperrcConfig.Producer {
private static final int Mb = 1024 * 1024;
/** List of all fields that should be bolded. */
private final Set<String> boldingFields = new java.util.LinkedHashSet<>();
/**
* Constructs a new juniper rc instance for a given search object.
* This will derive the configuration automatically,
* so there is no need to call {@link #derive(Schema)}.
*
* @param schema the search model to use for deriving
*/
public Juniperrc(Schema schema) {
derive(schema);
}
@Override
protected void derive(Schema schema) {
super.derive(schema);
for (SummaryField summaryField : schema.getUniqueNamedSummaryFields().values()) {
if (summaryField.getTransform() == SummaryTransform.BOLDED) {
boldingFields.add(summaryField.getName());
}
}
}
@Override
protected String getDerivedName() { return "juniperrc"; }
@Override
public void getConfig(JuniperrcConfig.Builder builder) {
if (boldingFields.size() != 0) {
builder.prefix(true);
for (String name : boldingFields) {
builder.override(new JuniperrcConfig.Override.Builder()
.fieldname(name)
.length(64*Mb)
.max_matches(1)
.min_length(8192)
.surround_max(64*Mb));
}
}
}
}
|