blob: 6427396ab8880aed762590f83a97b64a8e73d532 (
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
|
// Copyright 2017 Yahoo Holdings. 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.searchdefinition.document.SDField;
import com.yahoo.searchdefinition.Index;
import com.yahoo.searchdefinition.Search;
import com.yahoo.vespa.model.container.search.QueryProfiles;
import java.util.Iterator;
/**
* Fail if:
* 1) There are index: settings without explicit index names (name same as field name)
* 2) All the index-to indexes differ from the field name.
* @author vegardh
*
*/
public class IndexSettingsNonFieldNames extends Processor {
public IndexSettingsNonFieldNames(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) {
super(search, deployLogger, rankProfileRegistry, queryProfiles);
}
@Override
public void process() {
for (SDField field : search.allConcreteFields()) {
boolean fieldNameUsed = false;
for (Iterator i = field.getFieldNameAsIterator(); i.hasNext();) {
String iName = (String)(i.next());
if (iName.equals(field.getName())) {
fieldNameUsed = true;
}
}
if (!fieldNameUsed) {
for (Index index : field.getIndices().values()) {
if (index.getName().equals(field.getName())) {
throw new IllegalArgumentException("Error in " + field + " in " + search +
": When all index names differ from field name, index parameter settings must specify index name explicitly.");
}
}
}
}
}
}
|