diff --git a/docs/en/rest-api/ml/datafeedresource.asciidoc b/docs/en/rest-api/ml/datafeedresource.asciidoc index 65f5abf73c7..9df994fd592 100644 --- a/docs/en/rest-api/ml/datafeedresource.asciidoc +++ b/docs/en/rest-api/ml/datafeedresource.asciidoc @@ -30,7 +30,7 @@ A {dfeed} resource has the following properties: bucket spans, or, for longer bucket spans, a sensible fraction of the bucket span. For example: "150s" -`indexes` (required):: +`indices` (required):: (array) An array of index names. For example: ["it_ops_metrics"] `job_id` (required):: diff --git a/docs/en/rest-api/ml/put-datafeed.asciidoc b/docs/en/rest-api/ml/put-datafeed.asciidoc index 7f9e61b808d..c3b9709df74 100644 --- a/docs/en/rest-api/ml/put-datafeed.asciidoc +++ b/docs/en/rest-api/ml/put-datafeed.asciidoc @@ -38,7 +38,7 @@ You must create a job before you create a {dfeed}. You can associate only one bucket spans, or, for longer bucket spans, a sensible fraction of the bucket span. For example: "150s". -`indexes` (required):: +`indices` (required):: (array) An array of index names. Wildcards are supported. For example: ["it_ops_metrics", "server*"]. @@ -83,7 +83,7 @@ The following example creates the `datafeed-it-ops-kpi` {dfeed}: PUT _xpack/ml/datafeeds/datafeed-it-ops-kpi { "job_id": "it-ops-kpi", - "indexes": ["it_ops_metrics"], + "indices": ["it_ops_metrics"], "types": ["kpi","network","sql"], "query": { "match_all": { @@ -102,7 +102,7 @@ When the {dfeed} is created, you receive the following results: "datafeed_id": "datafeed-it-ops-kpi", "job_id": "it-ops-kpi", "query_delay": "1m", - "indexes": [ + "indices": [ "it_ops_metrics" ], "types": [ diff --git a/docs/en/rest-api/ml/update-datafeed.asciidoc b/docs/en/rest-api/ml/update-datafeed.asciidoc index 7aa6c5e9756..61b0b77ba7d 100644 --- a/docs/en/rest-api/ml/update-datafeed.asciidoc +++ b/docs/en/rest-api/ml/update-datafeed.asciidoc @@ -33,7 +33,7 @@ The following properties can be updated after the {dfeed} is created: bucket spans, or, for longer bucket spans, a sensible fraction of the bucket span. For example: "150s". -`indexes`:: +`indices`:: (array) An array of index names. Wildcards are supported. For example: ["it_ops_metrics", "server*"]. @@ -97,7 +97,7 @@ with the updated values: "datafeed_id": "datafeed-it-ops-kpi", "job_id": "it-ops-kpi", "query_delay": "1m", - "indexes": ["it-ops"], + "indices": ["it-ops"], "types": ["logs"], "query": { "term": { diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/PutDatafeedAction.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/PutDatafeedAction.java index 5386391aad6..fdf78b6d294 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/action/PutDatafeedAction.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/action/PutDatafeedAction.java @@ -233,8 +233,7 @@ public class PutDatafeedAction extends Action indices = datafeed.getIndexes(); + List indices = datafeed.getIndices(); for (String index : indices) { String[] concreteIndices; String reason = "cannot start datafeed [" + datafeed.getId() + "] because index [" diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfig.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfig.java index 65c5d342ecd..9f5fc7d109d 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfig.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedConfig.java @@ -63,6 +63,7 @@ public class DatafeedConfig extends AbstractDiffable implements public static final ParseField QUERY_DELAY = new ParseField("query_delay"); public static final ParseField FREQUENCY = new ParseField("frequency"); public static final ParseField INDEXES = new ParseField("indexes"); + public static final ParseField INDICES = new ParseField("indices"); public static final ParseField TYPES = new ParseField("types"); public static final ParseField QUERY = new ParseField("query"); public static final ParseField SCROLL_SIZE = new ParseField("scroll_size"); @@ -77,7 +78,8 @@ public class DatafeedConfig extends AbstractDiffable implements static { PARSER.declareString(Builder::setId, ID); PARSER.declareString(Builder::setJobId, Job.ID); - PARSER.declareStringArray(Builder::setIndexes, INDEXES); + PARSER.declareStringArray(Builder::setIndices, INDEXES); + PARSER.declareStringArray(Builder::setIndices, INDICES); PARSER.declareStringArray(Builder::setTypes, TYPES); PARSER.declareString((builder, val) -> builder.setQueryDelay(TimeValue.parseTimeValue(val, QUERY_DELAY.getPreferredName())), QUERY_DELAY); @@ -114,7 +116,7 @@ public class DatafeedConfig extends AbstractDiffable implements */ private final TimeValue frequency; - private final List indexes; + private final List indices; private final List types; private final QueryBuilder query; private final AggregatorFactories.Builder aggregations; @@ -123,14 +125,14 @@ public class DatafeedConfig extends AbstractDiffable implements private final boolean source; private final ChunkingConfig chunkingConfig; - private DatafeedConfig(String id, String jobId, TimeValue queryDelay, TimeValue frequency, List indexes, List types, + private DatafeedConfig(String id, String jobId, TimeValue queryDelay, TimeValue frequency, List indices, List types, QueryBuilder query, AggregatorFactories.Builder aggregations, List scriptFields, Integer scrollSize, boolean source, ChunkingConfig chunkingConfig) { this.id = id; this.jobId = jobId; this.queryDelay = queryDelay; this.frequency = frequency; - this.indexes = indexes; + this.indices = indices; this.types = types; this.query = query; this.aggregations = aggregations; @@ -146,9 +148,9 @@ public class DatafeedConfig extends AbstractDiffable implements this.queryDelay = in.readOptionalWriteable(TimeValue::new); this.frequency = in.readOptionalWriteable(TimeValue::new); if (in.readBoolean()) { - this.indexes = in.readList(StreamInput::readString); + this.indices = in.readList(StreamInput::readString); } else { - this.indexes = null; + this.indices = null; } if (in.readBoolean()) { this.types = in.readList(StreamInput::readString); @@ -183,8 +185,8 @@ public class DatafeedConfig extends AbstractDiffable implements return frequency; } - public List getIndexes() { - return indexes; + public List getIndices() { + return indices; } public List getTypes() { @@ -315,9 +317,9 @@ public class DatafeedConfig extends AbstractDiffable implements out.writeString(jobId); out.writeOptionalWriteable(queryDelay); out.writeOptionalWriteable(frequency); - if (indexes != null) { + if (indices != null) { out.writeBoolean(true); - out.writeStringList(indexes); + out.writeStringList(indices); } else { out.writeBoolean(false); } @@ -355,7 +357,7 @@ public class DatafeedConfig extends AbstractDiffable implements if (frequency != null) { builder.field(FREQUENCY.getPreferredName(), frequency.getStringRep()); } - builder.field(INDEXES.getPreferredName(), indexes); + builder.field(INDICES.getPreferredName(), indices); builder.field(TYPES.getPreferredName(), types); builder.field(QUERY.getPreferredName(), query); if (aggregations != null) { @@ -379,8 +381,8 @@ public class DatafeedConfig extends AbstractDiffable implements } /** - * The lists of indexes and types are compared for equality but they are not - * sorted first so this test could fail simply because the indexes and types + * The lists of indices and types are compared for equality but they are not + * sorted first so this test could fail simply because the indices and types * lists are in different orders. */ @Override @@ -399,7 +401,7 @@ public class DatafeedConfig extends AbstractDiffable implements && Objects.equals(this.jobId, that.jobId) && Objects.equals(this.frequency, that.frequency) && Objects.equals(this.queryDelay, that.queryDelay) - && Objects.equals(this.indexes, that.indexes) + && Objects.equals(this.indices, that.indices) && Objects.equals(this.types, that.types) && Objects.equals(this.query, that.query) && Objects.equals(this.scrollSize, that.scrollSize) @@ -411,7 +413,7 @@ public class DatafeedConfig extends AbstractDiffable implements @Override public int hashCode() { - return Objects.hash(id, jobId, frequency, queryDelay, indexes, types, query, scrollSize, aggregations, scriptFields, source, + return Objects.hash(id, jobId, frequency, queryDelay, indices, types, query, scrollSize, aggregations, scriptFields, source, chunkingConfig); } @@ -430,7 +432,7 @@ public class DatafeedConfig extends AbstractDiffable implements private String jobId; private TimeValue queryDelay = DEFAULT_QUERY_DELAY; private TimeValue frequency; - private List indexes = Collections.emptyList(); + private List indices = Collections.emptyList(); private List types = Collections.emptyList(); private QueryBuilder query = QueryBuilders.matchAllQuery(); private AggregatorFactories.Builder aggregations; @@ -453,7 +455,7 @@ public class DatafeedConfig extends AbstractDiffable implements this.jobId = config.jobId; this.queryDelay = config.queryDelay; this.frequency = config.frequency; - this.indexes = config.indexes; + this.indices = config.indices; this.types = config.types; this.query = config.query; this.aggregations = config.aggregations; @@ -471,8 +473,8 @@ public class DatafeedConfig extends AbstractDiffable implements this.jobId = ExceptionsHelper.requireNonNull(jobId, Job.ID.getPreferredName()); } - public void setIndexes(List indexes) { - this.indexes = ExceptionsHelper.requireNonNull(indexes, INDEXES.getPreferredName()); + public void setIndices(List indices) { + this.indices = ExceptionsHelper.requireNonNull(indices, INDICES.getPreferredName()); } public void setTypes(List types) { @@ -529,15 +531,15 @@ public class DatafeedConfig extends AbstractDiffable implements if (!MlStrings.isValidId(id)) { throw new IllegalArgumentException(Messages.getMessage(Messages.INVALID_ID, ID.getPreferredName())); } - if (indexes == null || indexes.isEmpty() || indexes.contains(null) || indexes.contains("")) { - throw invalidOptionValue(INDEXES.getPreferredName(), indexes); + 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("")) { throw invalidOptionValue(TYPES.getPreferredName(), types); } validateAggregations(); setDefaultChunkingConfig(); - return new DatafeedConfig(id, jobId, queryDelay, frequency, indexes, types, query, aggregations, scriptFields, scrollSize, + return new DatafeedConfig(id, jobId, queryDelay, frequency, indices, types, query, aggregations, scriptFields, scrollSize, source, chunkingConfig); } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedUpdate.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedUpdate.java index 9dccc305f38..1ef0e932183 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedUpdate.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/DatafeedUpdate.java @@ -40,7 +40,8 @@ public class DatafeedUpdate implements Writeable, ToXContent { static { PARSER.declareString(Builder::setId, DatafeedConfig.ID); PARSER.declareString(Builder::setJobId, Job.ID); - PARSER.declareStringArray(Builder::setIndexes, DatafeedConfig.INDEXES); + PARSER.declareStringArray(Builder::setIndices, DatafeedConfig.INDEXES); + PARSER.declareStringArray(Builder::setIndices, DatafeedConfig.INDICES); PARSER.declareStringArray(Builder::setTypes, DatafeedConfig.TYPES); PARSER.declareString((builder, val) -> builder.setQueryDelay( TimeValue.parseTimeValue(val, DatafeedConfig.QUERY_DELAY.getPreferredName())), DatafeedConfig.QUERY_DELAY); @@ -69,7 +70,7 @@ public class DatafeedUpdate implements Writeable, ToXContent { private final String jobId; private final TimeValue queryDelay; private final TimeValue frequency; - private final List indexes; + private final List indices; private final List types; private final QueryBuilder query; private final AggregatorFactories.Builder aggregations; @@ -78,14 +79,14 @@ public class DatafeedUpdate implements Writeable, ToXContent { private final Boolean source; private final ChunkingConfig chunkingConfig; - private DatafeedUpdate(String id, String jobId, TimeValue queryDelay, TimeValue frequency, List indexes, List types, + private DatafeedUpdate(String id, String jobId, TimeValue queryDelay, TimeValue frequency, List indices, List types, QueryBuilder query, AggregatorFactories.Builder aggregations, List scriptFields, Integer scrollSize, Boolean source, ChunkingConfig chunkingConfig) { this.id = id; this.jobId = jobId; this.queryDelay = queryDelay; this.frequency = frequency; - this.indexes = indexes; + this.indices = indices; this.types = types; this.query = query; this.aggregations = aggregations; @@ -101,9 +102,9 @@ public class DatafeedUpdate implements Writeable, ToXContent { this.queryDelay = in.readOptionalWriteable(TimeValue::new); this.frequency = in.readOptionalWriteable(TimeValue::new); if (in.readBoolean()) { - this.indexes = in.readList(StreamInput::readString); + this.indices = in.readList(StreamInput::readString); } else { - this.indexes = null; + this.indices = null; } if (in.readBoolean()) { this.types = in.readList(StreamInput::readString); @@ -135,9 +136,9 @@ public class DatafeedUpdate implements Writeable, ToXContent { out.writeOptionalString(jobId); out.writeOptionalWriteable(queryDelay); out.writeOptionalWriteable(frequency); - if (indexes != null) { + if (indices != null) { out.writeBoolean(true); - out.writeStringList(indexes); + out.writeStringList(indices); } else { out.writeBoolean(false); } @@ -171,7 +172,7 @@ public class DatafeedUpdate implements Writeable, ToXContent { if (frequency != null) { builder.field(DatafeedConfig.FREQUENCY.getPreferredName(), frequency.getStringRep()); } - addOptionalField(builder, DatafeedConfig.INDEXES, indexes); + addOptionalField(builder, DatafeedConfig.INDICES, indices); addOptionalField(builder, DatafeedConfig.TYPES, types); addOptionalField(builder, DatafeedConfig.QUERY, query); addOptionalField(builder, DatafeedConfig.AGGREGATIONS, aggregations); @@ -214,8 +215,8 @@ public class DatafeedUpdate implements Writeable, ToXContent { if (frequency != null) { builder.setFrequency(frequency); } - if (indexes != null) { - builder.setIndexes(indexes); + if (indices != null) { + builder.setIndices(indices); } if (types != null) { builder.setTypes(types); @@ -242,8 +243,8 @@ public class DatafeedUpdate implements Writeable, ToXContent { } /** - * The lists of indexes and types are compared for equality but they are not - * sorted first so this test could fail simply because the indexes and types + * The lists of indices and types are compared for equality but they are not + * sorted first so this test could fail simply because the indices and types * lists are in different orders. */ @Override @@ -262,7 +263,7 @@ public class DatafeedUpdate implements Writeable, ToXContent { && Objects.equals(this.jobId, that.jobId) && Objects.equals(this.frequency, that.frequency) && Objects.equals(this.queryDelay, that.queryDelay) - && Objects.equals(this.indexes, that.indexes) + && Objects.equals(this.indices, that.indices) && Objects.equals(this.types, that.types) && Objects.equals(this.query, that.query) && Objects.equals(this.scrollSize, that.scrollSize) @@ -274,7 +275,7 @@ public class DatafeedUpdate implements Writeable, ToXContent { @Override public int hashCode() { - return Objects.hash(id, jobId, frequency, queryDelay, indexes, types, query, scrollSize, aggregations, scriptFields, source, + return Objects.hash(id, jobId, frequency, queryDelay, indices, types, query, scrollSize, aggregations, scriptFields, source, chunkingConfig); } @@ -289,7 +290,7 @@ public class DatafeedUpdate implements Writeable, ToXContent { private String jobId; private TimeValue queryDelay; private TimeValue frequency; - private List indexes; + private List indices; private List types; private QueryBuilder query; private AggregatorFactories.Builder aggregations; @@ -310,7 +311,7 @@ public class DatafeedUpdate implements Writeable, ToXContent { this.jobId = config.jobId; this.queryDelay = config.queryDelay; this.frequency = config.frequency; - this.indexes = config.indexes; + this.indices = config.indices; this.types = config.types; this.query = config.query; this.aggregations = config.aggregations; @@ -328,8 +329,8 @@ public class DatafeedUpdate implements Writeable, ToXContent { this.jobId = jobId; } - public void setIndexes(List indexes) { - this.indexes = indexes; + public void setIndices(List indices) { + this.indices = indices; } public void setTypes(List types) { @@ -371,7 +372,7 @@ public class DatafeedUpdate implements Writeable, ToXContent { } public DatafeedUpdate build() { - return new DatafeedUpdate(id, jobId, queryDelay, frequency, indexes, types, query, aggregations, scriptFields, scrollSize, + return new DatafeedUpdate(id, jobId, queryDelay, frequency, indices, types, query, aggregations, scriptFields, scrollSize, source, chunkingConfig); } } diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractor.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractor.java index c90e4e6f49c..e83fe1f2dd2 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractor.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractor.java @@ -107,7 +107,7 @@ class AggregationDataExtractor implements DataExtractor { private SearchRequestBuilder buildSearchRequest() { SearchRequestBuilder searchRequestBuilder = SearchAction.INSTANCE.newRequestBuilder(client) - .setIndices(context.indexes) + .setIndices(context.indices) .setTypes(context.types) .setSize(0) .setQuery(ExtractorUtils.wrapInTimeRangeQuery(context.query, context.timeField, context.start, context.end)); diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorContext.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorContext.java index 5e179339bbc..e34fc8aa3e9 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorContext.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorContext.java @@ -15,7 +15,7 @@ class AggregationDataExtractorContext { final String jobId; final String timeField; - final String[] indexes; + final String[] indices; final String[] types; final QueryBuilder query; final AggregatorFactories.Builder aggs; @@ -23,11 +23,11 @@ class AggregationDataExtractorContext { final long end; final boolean includeDocCount; - AggregationDataExtractorContext(String jobId, String timeField, List indexes, List types, QueryBuilder query, + AggregationDataExtractorContext(String jobId, String timeField, List indices, List types, QueryBuilder query, AggregatorFactories.Builder aggs, long start, long end, boolean includeDocCount) { this.jobId = Objects.requireNonNull(jobId); this.timeField = Objects.requireNonNull(timeField); - this.indexes = indexes.toArray(new String[indexes.size()]); + this.indices = indices.toArray(new String[indices.size()]); this.types = types.toArray(new String[types.size()]); this.query = Objects.requireNonNull(query); this.aggs = Objects.requireNonNull(aggs); diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorFactory.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorFactory.java index ce7c92c22a0..3db0485b50b 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorFactory.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/aggregation/AggregationDataExtractorFactory.java @@ -30,7 +30,7 @@ public class AggregationDataExtractorFactory implements DataExtractorFactory { AggregationDataExtractorContext dataExtractorContext = new AggregationDataExtractorContext( job.getId(), job.getDataDescription().getTimeField(), - datafeedConfig.getIndexes(), + datafeedConfig.getIndices(), datafeedConfig.getTypes(), datafeedConfig.getQuery(), datafeedConfig.getAggregations(), diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractor.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractor.java index ef7059fe202..4014dae6fc9 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractor.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractor.java @@ -108,7 +108,7 @@ public class ChunkedDataExtractor implements DataExtractor { private DataSummary requestDataSummary() throws IOException { SearchRequestBuilder searchRequestBuilder = SearchAction.INSTANCE.newRequestBuilder(client) .setSize(0) - .setIndices(context.indexes) + .setIndices(context.indices) .setTypes(context.types) .setQuery(ExtractorUtils.wrapInTimeRangeQuery(context.query, context.timeField, currentStart, context.end)) .addAggregation(AggregationBuilders.min(EARLIEST_TIME).field(context.timeField)) diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorContext.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorContext.java index 61fc3ed0c6f..49720c69900 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorContext.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorContext.java @@ -16,7 +16,7 @@ class ChunkedDataExtractorContext { final String jobId; final String timeField; - final String[] indexes; + final String[] indices; final String[] types; final QueryBuilder query; final int scrollSize; @@ -24,11 +24,11 @@ class ChunkedDataExtractorContext { final long end; final TimeValue chunkSpan; - ChunkedDataExtractorContext(String jobId, String timeField, List indexes, List types, + ChunkedDataExtractorContext(String jobId, String timeField, List indices, List types, QueryBuilder query, int scrollSize, long start, long end, @Nullable TimeValue chunkSpan) { this.jobId = Objects.requireNonNull(jobId); this.timeField = Objects.requireNonNull(timeField); - this.indexes = indexes.toArray(new String[indexes.size()]); + this.indices = indices.toArray(new String[indices.size()]); this.types = types.toArray(new String[types.size()]); this.query = Objects.requireNonNull(query); this.scrollSize = scrollSize; diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorFactory.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorFactory.java index 17208b201b3..ef20672f6ff 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorFactory.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorFactory.java @@ -32,7 +32,7 @@ public class ChunkedDataExtractorFactory implements DataExtractorFactory { ChunkedDataExtractorContext dataExtractorContext = new ChunkedDataExtractorContext( job.getId(), job.getDataDescription().getTimeField(), - datafeedConfig.getIndexes(), + datafeedConfig.getIndices(), datafeedConfig.getTypes(), datafeedConfig.getQuery(), datafeedConfig.getScrollSize(), diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractor.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractor.java index 8f08ba85c8f..655d18645c9 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractor.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractor.java @@ -99,7 +99,7 @@ class ScrollDataExtractor implements DataExtractor { SearchRequestBuilder searchRequestBuilder = SearchAction.INSTANCE.newRequestBuilder(client) .setScroll(SCROLL_TIMEOUT) .addSort(context.extractedFields.timeField(), SortOrder.ASC) - .setIndices(context.indexes) + .setIndices(context.indices) .setTypes(context.types) .setSize(context.scrollSize) .setQuery(ExtractorUtils.wrapInTimeRangeQuery( diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorContext.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorContext.java index 80fe0922c8c..9a852e7c3d1 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorContext.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorContext.java @@ -15,7 +15,7 @@ class ScrollDataExtractorContext { final String jobId; final ExtractedFields extractedFields; - final String[] indexes; + final String[] indices; final String[] types; final QueryBuilder query; final List scriptFields; @@ -23,12 +23,12 @@ class ScrollDataExtractorContext { final long start; final long end; - ScrollDataExtractorContext(String jobId, ExtractedFields extractedFields, List indexes, List types, + ScrollDataExtractorContext(String jobId, ExtractedFields extractedFields, List indices, List types, QueryBuilder query, List scriptFields, int scrollSize, long start, long end) { this.jobId = Objects.requireNonNull(jobId); this.extractedFields = Objects.requireNonNull(extractedFields); - this.indexes = indexes.toArray(new String[indexes.size()]); + this.indices = indices.toArray(new String[indices.size()]); this.types = types.toArray(new String[types.size()]); this.query = Objects.requireNonNull(query); this.scriptFields = Objects.requireNonNull(scriptFields); diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorFactory.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorFactory.java index b50e30846bc..981b41a540e 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorFactory.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorFactory.java @@ -32,7 +32,7 @@ public class ScrollDataExtractorFactory implements DataExtractorFactory { ScrollDataExtractorContext dataExtractorContext = new ScrollDataExtractorContext( job.getId(), extractedFields, - datafeedConfig.getIndexes(), + datafeedConfig.getIndices(), datafeedConfig.getTypes(), datafeedConfig.getQuery(), datafeedConfig.getScriptFields(), diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/MlMetadataTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/MlMetadataTests.java index 8633a403ad0..966f1a63657 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/MlMetadataTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/MlMetadataTests.java @@ -251,7 +251,7 @@ public class MlMetadataTests extends AbstractSerializingTestCase { DatafeedConfig updatedDatafeed = updatedMetadata.getDatafeed(datafeedConfig1.getId()); assertThat(updatedDatafeed.getJobId(), equalTo(datafeedConfig1.getJobId())); - assertThat(updatedDatafeed.getIndexes(), equalTo(datafeedConfig1.getIndexes())); + assertThat(updatedDatafeed.getIndices(), equalTo(datafeedConfig1.getIndices())); assertThat(updatedDatafeed.getTypes(), equalTo(datafeedConfig1.getTypes())); assertThat(updatedDatafeed.getScrollSize(), equalTo(5000)); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionRequestTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionRequestTests.java index bac77589714..62ce5d922ef 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionRequestTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionRequestTests.java @@ -26,7 +26,7 @@ public class PutDatafeedActionRequestTests extends AbstractStreamableXContentTes @Override protected Request createTestInstance() { DatafeedConfig.Builder datafeedConfig = new DatafeedConfig.Builder(datafeedId, randomAlphaOfLength(10)); - datafeedConfig.setIndexes(Arrays.asList(randomAlphaOfLength(10))); + datafeedConfig.setIndices(Arrays.asList(randomAlphaOfLength(10))); datafeedConfig.setTypes(Arrays.asList(randomAlphaOfLength(10))); return new Request(datafeedConfig.build()); } diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionResponseTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionResponseTests.java index a6990722949..ef133ad42d7 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionResponseTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/action/PutDatafeedActionResponseTests.java @@ -18,7 +18,7 @@ public class PutDatafeedActionResponseTests extends AbstractStreamableTestCase conf.setIndexes(null)); + expectThrows(IllegalArgumentException.class, () -> conf.setIndices(null)); } - public void testCheckValid_GivenEmptyIndexes() throws IOException { + public void testCheckValid_GivenEmptyIndices() throws IOException { DatafeedConfig.Builder conf = new DatafeedConfig.Builder("datafeed1", "job1"); - conf.setIndexes(Collections.emptyList()); + conf.setIndices(Collections.emptyList()); IllegalArgumentException e = ESTestCase.expectThrows(IllegalArgumentException.class, conf::build); - assertEquals(Messages.getMessage(Messages.DATAFEED_CONFIG_INVALID_OPTION_VALUE, "indexes", "[]"), e.getMessage()); + assertEquals(Messages.getMessage(Messages.DATAFEED_CONFIG_INVALID_OPTION_VALUE, "indices", "[]"), e.getMessage()); } - public void testCheckValid_GivenIndexesContainsOnlyNulls() throws IOException { - List indexes = new ArrayList<>(); - indexes.add(null); - indexes.add(null); + public void testCheckValid_GivenIndicesContainsOnlyNulls() throws IOException { + List indices = new ArrayList<>(); + indices.add(null); + indices.add(null); DatafeedConfig.Builder conf = new DatafeedConfig.Builder("datafeed1", "job1"); - conf.setIndexes(indexes); + conf.setIndices(indices); IllegalArgumentException e = ESTestCase.expectThrows(IllegalArgumentException.class, conf::build); - assertEquals(Messages.getMessage(Messages.DATAFEED_CONFIG_INVALID_OPTION_VALUE, "indexes", "[null, null]"), e.getMessage()); + assertEquals(Messages.getMessage(Messages.DATAFEED_CONFIG_INVALID_OPTION_VALUE, "indices", "[null, null]"), e.getMessage()); } - public void testCheckValid_GivenIndexesContainsOnlyEmptyStrings() throws IOException { - List indexes = new ArrayList<>(); - indexes.add(""); - indexes.add(""); + public void testCheckValid_GivenIndicesContainsOnlyEmptyStrings() throws IOException { + List indices = new ArrayList<>(); + indices.add(""); + indices.add(""); DatafeedConfig.Builder conf = new DatafeedConfig.Builder("datafeed1", "job1"); - conf.setIndexes(indexes); + conf.setIndices(indices); IllegalArgumentException e = ESTestCase.expectThrows(IllegalArgumentException.class, conf::build); - assertEquals(Messages.getMessage(Messages.DATAFEED_CONFIG_INVALID_OPTION_VALUE, "indexes", "[, ]"), e.getMessage()); + assertEquals(Messages.getMessage(Messages.DATAFEED_CONFIG_INVALID_OPTION_VALUE, "indices", "[, ]"), e.getMessage()); } public void testCheckValid_GivenNegativeQueryDelay() throws IOException { @@ -189,7 +189,7 @@ public class DatafeedConfigTests extends AbstractSerializingTestCase types; - private List indexes; + private List indices; private QueryBuilder query; private AggregatorFactories.Builder aggs; @@ -79,7 +79,7 @@ public class AggregationDataExtractorTests extends ESTestCase { capturedSearchRequests = new ArrayList<>(); jobId = "test-job"; timeField = "time"; - indexes = Arrays.asList("index-1", "index-2"); + indices = Arrays.asList("index-1", "index-2"); types = Arrays.asList("type-1", "type-2"); query = QueryBuilders.matchAllQuery(); aggs = new AggregatorFactories.Builder() @@ -270,7 +270,7 @@ public class AggregationDataExtractorTests extends ESTestCase { } private AggregationDataExtractorContext createContext(long start, long end) { - return new AggregationDataExtractorContext(jobId, timeField, indexes, types, query, aggs, start, end, true); + return new AggregationDataExtractorContext(jobId, timeField, indices, types, query, aggs, start, end, true); } @SuppressWarnings("unchecked") diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorTests.java index 550189b046f..dee69494854 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/chunked/ChunkedDataExtractorTests.java @@ -48,7 +48,7 @@ public class ChunkedDataExtractorTests extends ESTestCase { private String jobId; private String timeField; private List types; - private List indexes; + private List indices; private QueryBuilder query; private int scrollSize; private TimeValue chunkSpan; @@ -79,7 +79,7 @@ public class ChunkedDataExtractorTests extends ESTestCase { capturedSearchRequests = new ArrayList<>(); jobId = "test-job"; timeField = "time"; - indexes = Arrays.asList("index-1", "index-2"); + indices = Arrays.asList("index-1", "index-2"); types = Arrays.asList("type-1", "type-2"); query = QueryBuilders.matchAllQuery(); scrollSize = 1000; @@ -445,7 +445,7 @@ public class ChunkedDataExtractorTests extends ESTestCase { } private ChunkedDataExtractorContext createContext(long start, long end) { - return new ChunkedDataExtractorContext(jobId, timeField, indexes, types, query, scrollSize, start, end, chunkSpan); + return new ChunkedDataExtractorContext(jobId, timeField, indices, types, query, scrollSize, start, end, chunkSpan); } private static class StubSubExtractor implements DataExtractor { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorTests.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorTests.java index 101723485f7..94da286f67f 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/datafeed/extractor/scroll/ScrollDataExtractorTests.java @@ -51,7 +51,7 @@ public class ScrollDataExtractorTests extends ESTestCase { private String jobId; private ExtractedFields extractedFields; private List types; - private List indexes; + private List indices; private QueryBuilder query; private List scriptFields; private int scrollSize; @@ -100,7 +100,7 @@ public class ScrollDataExtractorTests extends ESTestCase { ExtractedField timeField = ExtractedField.newField("time", ExtractedField.ExtractionMethod.DOC_VALUE); extractedFields = new ExtractedFields(timeField, Arrays.asList(timeField, ExtractedField.newField("field_1", ExtractedField.ExtractionMethod.DOC_VALUE))); - indexes = Arrays.asList("index-1", "index-2"); + indices = Arrays.asList("index-1", "index-2"); types = Arrays.asList("type-1", "type-2"); query = QueryBuilders.matchAllQuery(); scriptFields = Collections.emptyList(); @@ -285,7 +285,7 @@ public class ScrollDataExtractorTests extends ESTestCase { "script2", new Script(ScriptType.INLINE, "painless", "return domainSplit('foo.com', params);", emptyMap()), false); List sFields = Arrays.asList(withoutSplit, withSplit); - ScrollDataExtractorContext context = new ScrollDataExtractorContext(jobId, extractedFields, indexes, + ScrollDataExtractorContext context = new ScrollDataExtractorContext(jobId, extractedFields, indices, types, query, sFields, scrollSize, 1000, 2000); TestDataExtractor extractor = new TestDataExtractor(context); @@ -332,7 +332,7 @@ public class ScrollDataExtractorTests extends ESTestCase { } private ScrollDataExtractorContext createContext(long start, long end) { - return new ScrollDataExtractorContext(jobId, extractedFields, indexes, types, query, scriptFields, scrollSize, start, end); + return new ScrollDataExtractorContext(jobId, extractedFields, indices, types, query, scriptFields, scrollSize, start, end); } private SearchResponse createEmptySearchResponse() { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/CategorizationIT.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/CategorizationIT.java index 6c5202893f3..f4c3c23931e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/CategorizationIT.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/CategorizationIT.java @@ -89,7 +89,7 @@ public class CategorizationIT extends MlNativeAutodetectIntegTestCase { String datafeedId = job.getId() + "-feed"; DatafeedConfig.Builder datafeedConfig = new DatafeedConfig.Builder(datafeedId, job.getId()); - datafeedConfig.setIndexes(Arrays.asList(DATA_INDEX)); + datafeedConfig.setIndices(Arrays.asList(DATA_INDEX)); datafeedConfig.setTypes(Arrays.asList(DATA_TYPE)); DatafeedConfig datafeed = datafeedConfig.build(); registerDatafeed(datafeed); @@ -135,7 +135,7 @@ public class CategorizationIT extends MlNativeAutodetectIntegTestCase { String datafeedId = job.getId() + "-feed"; DatafeedConfig.Builder datafeedConfig = new DatafeedConfig.Builder(datafeedId, job.getId()); - datafeedConfig.setIndexes(Arrays.asList(DATA_INDEX)); + datafeedConfig.setIndices(Arrays.asList(DATA_INDEX)); datafeedConfig.setTypes(Arrays.asList(DATA_TYPE)); DatafeedConfig datafeed = datafeedConfig.build(); registerDatafeed(datafeed); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsRestIT.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsRestIT.java index dcd0994fdac..ec95a2983cf 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsRestIT.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DatafeedJobsRestIT.java @@ -265,7 +265,7 @@ public class DatafeedJobsRestIT extends ESRestTestCase { assertThat(e.getMessage(), containsString("Cannot create datafeed")); assertThat(e.getMessage(), - containsString("user ml_admin lacks permissions on the indexes to be searched")); + containsString("user ml_admin lacks permissions on the indices to be searched")); } public void testInsufficientSearchPrivilegesOnPreview() throws Exception { diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteExpiredDataIT.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteExpiredDataIT.java index f3de78732d7..65a2fe010fa 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteExpiredDataIT.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/integration/DeleteExpiredDataIT.java @@ -95,7 +95,7 @@ public class DeleteExpiredDataIT extends MlNativeAutodetectIntegTestCase { String datafeedId = job.getId() + "-feed"; DatafeedConfig.Builder datafeedConfig = new DatafeedConfig.Builder(datafeedId, job.getId()); - datafeedConfig.setIndexes(Arrays.asList(DATA_INDEX)); + datafeedConfig.setIndices(Arrays.asList(DATA_INDEX)); datafeedConfig.setTypes(Arrays.asList(DATA_TYPE)); DatafeedConfig datafeed = datafeedConfig.build(); registerDatafeed(datafeed); diff --git a/plugin/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java b/plugin/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java index 400ef0c5c0e..9ec8af4af2f 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/ml/support/BaseMlIntegTestCase.java @@ -164,15 +164,15 @@ public abstract class BaseMlIntegTestCase extends ESIntegTestCase { return builder; } - public static DatafeedConfig createDatafeed(String datafeedId, String jobId, List indexes) { - return createDatafeedBuilder(datafeedId, jobId, indexes).build(); + public static DatafeedConfig createDatafeed(String datafeedId, String jobId, List indices) { + return createDatafeedBuilder(datafeedId, jobId, indices).build(); } - public static DatafeedConfig.Builder createDatafeedBuilder(String datafeedId, String jobId, List indexes) { + public static DatafeedConfig.Builder createDatafeedBuilder(String datafeedId, String jobId, List indices) { DatafeedConfig.Builder builder = new DatafeedConfig.Builder(datafeedId, jobId); builder.setQueryDelay(TimeValue.timeValueSeconds(1)); builder.setFrequency(TimeValue.timeValueSeconds(2)); - builder.setIndexes(indexes); + builder.setIndices(indices); builder.setTypes(Collections.singletonList("type")); return builder; } diff --git a/plugin/src/test/resources/rest-api-spec/test/ml/datafeeds_crud.yaml b/plugin/src/test/resources/rest-api-spec/test/ml/datafeeds_crud.yaml index 17622d241cf..206041f03cd 100644 --- a/plugin/src/test/resources/rest-api-spec/test/ml/datafeeds_crud.yaml +++ b/plugin/src/test/resources/rest-api-spec/test/ml/datafeeds_crud.yaml @@ -71,7 +71,7 @@ setup: } - match: { datafeed_id: "test-datafeed-1" } - match: { job_id: "datafeeds-crud-1" } - - match: { indexes: ["index-foo"] } + - match: { indices: ["index-foo"] } - match: { types: ["type-bar"] } - match: { scroll_size: 1000 } - is_true: query.match_all @@ -166,7 +166,7 @@ setup: } - match: { datafeed_id: "test-datafeed-1" } - match: { job_id: "datafeeds-crud-1" } - - match: { indexes: ["index-*"] } + - match: { indices: ["index-*"] } - match: { types: ["type-bar"] } - match: { scroll_size: 10000 } - match: { frequency: "2m" } @@ -194,7 +194,7 @@ setup: } - match: { datafeed_id: "test-datafeed-1" } - match: { job_id: "datafeeds-crud-2" } - - match: { indexes: ["index-foo"] } + - match: { indices: ["index-foo"] } - match: { types: ["type-bar"] } --- @@ -275,7 +275,7 @@ setup: body: > { "job_id":"datafeeds-crud-1", - "indexes":["index-foo"], + "indices":["index-foo"], "types":["type-bar"], "chunking_config": {"mode":"manual","time_span": "1h"} }