Fix spacing, assert key contains period
This commit is contained in:
parent
f8d2400ee6
commit
198a79edf5
|
@ -136,12 +136,13 @@ public final class IndexScopedSettings extends AbstractScopedSettings {
|
|||
IndexWarmer.INDEX_NORMS_LOADING_SETTING,
|
||||
// validate that built-in similarities don't get redefined
|
||||
Setting.groupSetting("index.similarity.", false, Setting.Scope.INDEX, (s) -> {
|
||||
boolean valid = true;
|
||||
String similarityName = s.substring(0, s.indexOf("."));
|
||||
if(SimilarityService.BUILT_IN.keySet().contains(similarityName)) {
|
||||
throw new IllegalArgumentException("Cannot redefine built-in Similarity [" + similarityName + "]");
|
||||
}
|
||||
return valid;
|
||||
boolean valid = true;
|
||||
assert(s.indexOf(".") > 1);
|
||||
String similarityName = s.substring(0, s.indexOf("."));
|
||||
if(SimilarityService.BUILT_IN.keySet().contains(similarityName)) {
|
||||
throw new IllegalArgumentException("Cannot redefine built-in Similarity [" + similarityName + "]");
|
||||
}
|
||||
return valid;
|
||||
}), // this allows similarity settings to be passed
|
||||
Setting.groupSetting("index.analysis.", false, Setting.Scope.INDEX) // this allows analysis settings to be passed
|
||||
|
||||
|
|
|
@ -487,7 +487,7 @@ public class Setting<T> extends ToXContentToBytes {
|
|||
}
|
||||
|
||||
public static Setting<Settings> groupSetting(String key, boolean dynamic, Scope scope) {
|
||||
return groupSetting(key, dynamic, scope, (s) -> true);
|
||||
return groupSetting(key, dynamic, scope, (s) -> true);
|
||||
}
|
||||
|
||||
public static Setting<Settings> groupSetting(String key, boolean dynamic, Scope scope, Predicate<String> settingsValidator) {
|
||||
|
|
|
@ -114,7 +114,7 @@ public final class SimilarityService extends AbstractIndexComponent {
|
|||
}
|
||||
providers.put(name, factory.apply(name, settings));
|
||||
}
|
||||
return providers;
|
||||
return providers;
|
||||
}
|
||||
|
||||
public SimilarityProvider getSimilarity(String name) {
|
||||
|
@ -122,7 +122,7 @@ public final class SimilarityService extends AbstractIndexComponent {
|
|||
}
|
||||
|
||||
public SimilarityProvider getDefaultSimilarity() {
|
||||
return similarities.get("default");
|
||||
return similarities.get("default");
|
||||
}
|
||||
|
||||
static class PerFieldSimilarity extends PerFieldSimilarityWrapper {
|
||||
|
|
|
@ -215,10 +215,10 @@ public class ScopedSettingsTests extends ESTestCase {
|
|||
}
|
||||
|
||||
try {
|
||||
settings.validate("index.similarity.classic.type", Settings.builder().put("index.similarity.classic.type", "mine").build());
|
||||
fail();
|
||||
settings.validate("index.similarity.classic.type", Settings.builder().put("index.similarity.classic.type", "mine").build());
|
||||
fail();
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertEquals("Cannot redefine built-in Similarity [classic]", e.getMessage());
|
||||
assertEquals("Cannot redefine built-in Similarity [classic]", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue