@@ -282,6 +282,18 @@ public final void validate(final Settings settings, final boolean validateDepend
282282 validate (settings , validateDependencies , false , false );
283283 }
284284
285+ /**
286+ * Validates that all settings are registered and valid.
287+ *
288+ * @param settings the settings to validate
289+ * @param validateDependencies true if dependent settings should be validated
290+ * @param validateInternalIndex true if internal index settings should be validated
291+ * @see Setting#getSettingsDependencies(String)
292+ */
293+ public final void validate (final Settings settings , final boolean validateDependencies , final boolean validateInternalIndex ) {
294+ validate (settings , validateDependencies , false , false , validateInternalIndex );
295+ }
296+
285297 /**
286298 * Validates that all settings are registered and valid.
287299 *
@@ -296,6 +308,25 @@ public final void validate(
296308 final boolean validateDependencies ,
297309 final boolean ignorePrivateSettings ,
298310 final boolean ignoreArchivedSettings ) {
311+ validate (settings , validateDependencies , ignorePrivateSettings , ignoreArchivedSettings , false );
312+ }
313+
314+ /**
315+ * Validates that all settings are registered and valid.
316+ *
317+ * @param settings the settings
318+ * @param validateDependencies true if dependent settings should be validated
319+ * @param ignorePrivateSettings true if private settings should be ignored during validation
320+ * @param ignoreArchivedSettings true if archived settings should be ignored during validation
321+ * @param validateInternalIndex true if index internal settings should be validated
322+ * @see Setting#getSettingsDependencies(String)
323+ */
324+ public final void validate (
325+ final Settings settings ,
326+ final boolean validateDependencies ,
327+ final boolean ignorePrivateSettings ,
328+ final boolean ignoreArchivedSettings ,
329+ final boolean validateInternalIndex ) {
299330 final List <RuntimeException > exceptions = new ArrayList <>();
300331 for (final String key : settings .keySet ()) { // settings iterate in deterministic fashion
301332 if (isPrivateSetting (key ) && ignorePrivateSettings ) {
@@ -305,7 +336,7 @@ public final void validate(
305336 continue ;
306337 }
307338 try {
308- validate (key , settings , validateDependencies );
339+ validate (key , settings , validateDependencies , validateInternalIndex );
309340 } catch (final RuntimeException ex ) {
310341 exceptions .add (ex );
311342 }
@@ -314,9 +345,27 @@ public final void validate(
314345 }
315346
316347 /**
317- * Validates that the setting is valid
348+ * Validates that the settings is valid.
349+ *
350+ * @param key the key of the setting to validate
351+ * @param settings the settings
352+ * @param validateDependencies true if dependent settings should be validated
353+ * @throws IllegalArgumentException if the setting is invalid
318354 */
319- void validate (String key , Settings settings , boolean validateDependencies ) {
355+ void validate (final String key , final Settings settings , final boolean validateDependencies ) {
356+ validate (key , settings , validateDependencies , false );
357+ }
358+
359+ /**
360+ * Validates that the settings is valid.
361+ *
362+ * @param key the key of the setting to validate
363+ * @param settings the settings
364+ * @param validateDependencies true if dependent settings should be validated
365+ * @param validateInternalIndex true if internal index settings should be validated
366+ * @throws IllegalArgumentException if the setting is invalid
367+ */
368+ void validate (final String key , final Settings settings , final boolean validateDependencies , final boolean validateInternalIndex ) {
320369 Setting setting = getRaw (key );
321370 if (setting == null ) {
322371 LevensteinDistance ld = new LevensteinDistance ();
@@ -356,6 +405,11 @@ void validate(String key, Settings settings, boolean validateDependencies) {
356405 }
357406 }
358407 }
408+ // the only time that validateInternalIndex should be true is if this call is coming via the update settings API
409+ if (validateInternalIndex && setting .getProperties ().contains (Setting .Property .InternalIndex )) {
410+ throw new IllegalArgumentException (
411+ "can not update internal setting [" + setting .getKey () + "]; this setting is managed via a dedicated API" );
412+ }
359413 }
360414 setting .get (settings );
361415 }
0 commit comments