Revert "[ML] Check influencer names are valid (elastic/x-pack-elasticsearch#2073)"
This reverts commit elastic/x-pack-elasticsearch@75869cacb3. Original commit: elastic/x-pack-elasticsearch@1f582ed260
This commit is contained in:
parent
03ec9df1d8
commit
b818ee285b
|
@ -36,6 +36,7 @@ import java.util.regex.Pattern;
|
|||
import java.util.regex.PatternSyntaxException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* Autodetect analysis configuration options describes which fields are
|
||||
* analysed and the functions to use.
|
||||
|
@ -557,7 +558,6 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|||
}
|
||||
|
||||
verifyNoInconsistentNestedFieldNames();
|
||||
verifyInfluencerNames();
|
||||
|
||||
return new AnalysisConfig(bucketSpan, categorizationFieldName, categorizationFilters,
|
||||
latency, summaryCountFieldName, detectors, influencers, overlappingBuckets,
|
||||
|
@ -675,17 +675,6 @@ public class AnalysisConfig implements ToXContentObject, Writeable {
|
|||
}
|
||||
}
|
||||
|
||||
private void verifyInfluencerNames() {
|
||||
for (String influencer : influencers) {
|
||||
if (influencer == null || influencer.isEmpty()) {
|
||||
throw ExceptionsHelper.badRequestException(
|
||||
Messages.getMessage(Messages.JOB_CONFIG_INFLUENCER_CANNOT_BE_EMPTY));
|
||||
}
|
||||
|
||||
Detector.Builder.verifyFieldName(influencer);
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkDetectorsHavePartitionFields(List<Detector> detectors) {
|
||||
for (Detector detector : detectors) {
|
||||
if (!Strings.isNullOrEmpty(detector.getPartitionFieldName())) {
|
||||
|
|
|
@ -112,11 +112,10 @@ public final class Messages {
|
|||
public static final String JOB_CONFIG_FUNCTION_REQUIRES_OVERFIELD = "over_field_name must be set when the ''{0}'' function is used";
|
||||
public static final String JOB_CONFIG_ID_ALREADY_TAKEN = "The job cannot be created with the Id ''{0}''. The Id is already used.";
|
||||
public static final String JOB_CONFIG_ID_TOO_LONG = "The job id cannot contain more than {0,number,integer} characters.";
|
||||
public static final String JOB_CONFIG_INFLUENCER_CANNOT_BE_EMPTY = "Influencer names cannot be empty strings";
|
||||
public static final String JOB_CONFIG_INVALID_CREATE_SETTINGS =
|
||||
"The job is configured with fields [{0}] that are illegal to set at job creation";
|
||||
public static final String JOB_CONFIG_INVALID_FIELDNAME_CHARS =
|
||||
"Invalid field name ''{0}''. Field names cannot contain any of these characters: {1}";
|
||||
"Invalid field name ''{0}''. Field names including over, by and partition fields cannot contain any of these characters: {1}";
|
||||
public static final String JOB_CONFIG_INVALID_FIELDNAME =
|
||||
"Invalid field name ''{0}''. Field names including over, by and partition fields cannot be ''{1}''";
|
||||
public static final String JOB_CONFIG_INVALID_TIMEFORMAT = "Invalid Time format string ''{0}''";
|
||||
|
|
|
@ -791,20 +791,6 @@ public class AnalysisConfigTests extends AbstractSerializingTestCase<AnalysisCon
|
|||
assertEquals(Messages.getMessage(Messages.JOB_CONFIG_PER_PARTITION_NORMALIZATION_CANNOT_USE_INFLUENCERS), e.getMessage());
|
||||
}
|
||||
|
||||
public void testVerifyInfluencerNames() {
|
||||
AnalysisConfig.Builder config = createValidConfig();
|
||||
Detector.Builder builder = new Detector.Builder(config.build().getDetectors().get(0));
|
||||
config.build().getDetectors().set(0, builder.build());
|
||||
|
||||
config.setInfluencers(Arrays.asList("inf1", ""));
|
||||
ElasticsearchException e = ESTestCase.expectThrows(ElasticsearchException.class, config::build);
|
||||
assertEquals("Influencer names cannot be empty strings", e.getMessage());
|
||||
|
||||
config.setInfluencers(Arrays.asList("invalid\\backslash"));
|
||||
e = ESTestCase.expectThrows(ElasticsearchException.class, config::build);
|
||||
assertEquals("Invalid field name 'invalid\\backslash'. Field names cannot contain any of these characters: \",\\", e.getMessage());
|
||||
}
|
||||
|
||||
public void testVerify_GivenCategorizationFiltersContainInvalidRegex() {
|
||||
AnalysisConfig.Builder config = createValidCategorizationConfig();
|
||||
config.setCategorizationFilters(Arrays.asList("foo", "("));
|
||||
|
|
Loading…
Reference in New Issue