[ML] Make datafeed types optional (elastic/x-pack-elasticsearch#1690)

Specifying types for a datafeed should be optional
as no types is equal to searching through all types.

Original commit: elastic/x-pack-elasticsearch@f61ac01b45
This commit is contained in:
Dimitris Athanasiou 2017-06-12 14:46:53 +01:00 committed by GitHub
parent 27b5142de6
commit c9bbc17742
2 changed files with 2 additions and 4 deletions

View File

@ -534,7 +534,7 @@ public class DatafeedConfig extends AbstractDiffable<DatafeedConfig> implements
if (indices == null || indices.isEmpty() || indices.contains(null) || indices.contains("")) {
throw invalidOptionValue(INDICES.getPreferredName(), indices);
}
if (types == null || types.isEmpty() || types.contains(null) || types.contains("")) {
if (types == null || types.contains(null) || types.contains("")) {
throw invalidOptionValue(TYPES.getPreferredName(), types);
}
validateAggregations();

View File

@ -46,7 +46,7 @@ public class DatafeedConfigTests extends AbstractSerializingTestCase<DatafeedCon
public static DatafeedConfig createRandomizedDatafeedConfig(String jobId, long bucketSpanMillis) {
DatafeedConfig.Builder builder = new DatafeedConfig.Builder(randomValidDatafeedId(), jobId);
builder.setIndices(randomStringList(1, 10));
builder.setTypes(randomStringList(1, 10));
builder.setTypes(randomStringList(0, 10));
if (randomBoolean()) {
builder.setQuery(QueryBuilders.termQuery(randomAlphaOfLength(10), randomAlphaOfLength(10)));
}
@ -119,12 +119,10 @@ public class DatafeedConfigTests extends AbstractSerializingTestCase<DatafeedCon
public void testFillDefaults() {
DatafeedConfig.Builder expectedDatafeedConfig = new DatafeedConfig.Builder("datafeed1", "job1");
expectedDatafeedConfig.setIndices(Collections.singletonList("index"));
expectedDatafeedConfig.setTypes(Collections.singletonList("type"));
expectedDatafeedConfig.setQueryDelay(TimeValue.timeValueMinutes(1));
expectedDatafeedConfig.setScrollSize(1000);
DatafeedConfig.Builder defaultedDatafeedConfig = new DatafeedConfig.Builder("datafeed1", "job1");
defaultedDatafeedConfig.setIndices(Collections.singletonList("index"));
defaultedDatafeedConfig.setTypes(Collections.singletonList("type"));
assertEquals(expectedDatafeedConfig.build(), defaultedDatafeedConfig.build());
}