diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexSettingsNonFieldNames.java |
Publish
Diffstat (limited to 'config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexSettingsNonFieldNames.java')
-rw-r--r-- | config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexSettingsNonFieldNames.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexSettingsNonFieldNames.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexSettingsNonFieldNames.java new file mode 100644 index 00000000000..fecc5e2309d --- /dev/null +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/IndexSettingsNonFieldNames.java @@ -0,0 +1,47 @@ +// 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.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.allFieldsList()) { + 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."); + } + } + } + } + } + +} |