blob: 231a97f30eca6e88cb26ece50838b8c2665e2bd2 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing.multifieldresolver;
import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.searchdefinition.document.RankType;
import com.yahoo.searchdefinition.document.SDField;
import com.yahoo.searchdefinition.Schema;
import java.util.List;
import java.util.logging.Level;
/**
* Checks if fields have defined different rank types for the same
* index (typically in an index-to statement), and if they have
* output a warning and use the first ranktype.
*
* @author hmusum
*/
public class RankTypeResolver extends MultiFieldResolver {
public RankTypeResolver(String indexName, List<SDField> fields, Schema schema, DeployLogger logger) {
super(indexName, fields, schema, logger);
}
public void resolve() {
RankType rankType = null;
if (fields.size() > 0) {
boolean first = true;
for (SDField field : fields) {
if (first) {
rankType = fields.get(0).getRankType();
first = false;
} else if (!field.getRankType().equals(rankType)) {
deployLogger.logApplicationPackage(Level.WARNING, "In field '" + field.getName() + "' " +
field.getRankType() + " for index '" + indexName +
"' conflicts with " + rankType +
" defined for the same index in field '" +
field.getName() + "'. Using " +
rankType + ".");
field.setRankType(rankType);
}
}
}
}
}
|