blob: 45b50c808f9519e349424add256574bdbe2d8837 (
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
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing;
import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.searchdefinition.RankProfileRegistry;
import com.yahoo.document.*;
import com.yahoo.searchdefinition.Search;
import com.yahoo.searchdefinition.document.SDField;
import com.yahoo.vespa.documentmodel.SummaryField;
import com.yahoo.vespa.documentmodel.SummaryTransform;
import com.yahoo.vespa.model.container.search.QueryProfiles;
/**
* Fail if:
* An SD field explicitly says summary:dynamic , but the field is wset, array or struct.
* If there is an explicitly defined summary class, saying dynamic in one of its summary
* fields is always legal.
* @author vegardh
*
*/
public class SummaryDynamicStructsArrays extends Processor {
public SummaryDynamicStructsArrays(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) {
super(search, deployLogger, rankProfileRegistry, queryProfiles);
}
@Override
public void process() {
for (SDField field : search.allConcreteFields()) {
DataType type = field.getDataType();
if (type instanceof ArrayDataType || type instanceof WeightedSetDataType
|| type instanceof StructDataType) {
for (SummaryField sField : field.getSummaryFields()) {
if (sField.getTransform().equals(SummaryTransform.DYNAMICTEASER)) {
throw new IllegalArgumentException("For field '"+field.getName()+"': dynamic summary is illegal " +
"for fields of type struct, array or weighted set. Use an explicit summary class with explicit summary fields sourcing from" +
" the array/struct/weighted set.");
}
}
}
}
}
}
|