Part of the endpoint rename Sophie and Steve agreed with Clint

Relates elastic/elasticsearch#630

Original commit: elastic/x-pack-elasticsearch@6ded117849
This commit is contained in:
David Roberts 2017-01-24 10:01:24 +00:00 committed by GitHub
parent a7d1918461
commit 215410e93f
40 changed files with 419 additions and 422 deletions

View File

@ -35,7 +35,7 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.watcher.ResourceWatcherService; import org.elasticsearch.watcher.ResourceWatcherService;
import org.elasticsearch.xpack.ml.action.CloseJobAction; import org.elasticsearch.xpack.ml.action.CloseJobAction;
import org.elasticsearch.xpack.ml.action.DeleteJobAction; import org.elasticsearch.xpack.ml.action.DeleteJobAction;
import org.elasticsearch.xpack.ml.action.DeleteListAction; import org.elasticsearch.xpack.ml.action.DeleteFilterAction;
import org.elasticsearch.xpack.ml.action.DeleteModelSnapshotAction; import org.elasticsearch.xpack.ml.action.DeleteModelSnapshotAction;
import org.elasticsearch.xpack.ml.action.DeleteDatafeedAction; import org.elasticsearch.xpack.ml.action.DeleteDatafeedAction;
import org.elasticsearch.xpack.ml.action.FlushJobAction; import org.elasticsearch.xpack.ml.action.FlushJobAction;
@ -44,7 +44,7 @@ import org.elasticsearch.xpack.ml.action.GetCategoriesAction;
import org.elasticsearch.xpack.ml.action.GetInfluencersAction; import org.elasticsearch.xpack.ml.action.GetInfluencersAction;
import org.elasticsearch.xpack.ml.action.GetJobsAction; import org.elasticsearch.xpack.ml.action.GetJobsAction;
import org.elasticsearch.xpack.ml.action.GetJobsStatsAction; import org.elasticsearch.xpack.ml.action.GetJobsStatsAction;
import org.elasticsearch.xpack.ml.action.GetListAction; import org.elasticsearch.xpack.ml.action.GetFiltersAction;
import org.elasticsearch.xpack.ml.action.GetModelSnapshotsAction; import org.elasticsearch.xpack.ml.action.GetModelSnapshotsAction;
import org.elasticsearch.xpack.ml.action.GetRecordsAction; import org.elasticsearch.xpack.ml.action.GetRecordsAction;
import org.elasticsearch.xpack.ml.action.GetDatafeedsAction; import org.elasticsearch.xpack.ml.action.GetDatafeedsAction;
@ -54,7 +54,7 @@ import org.elasticsearch.xpack.ml.action.InternalOpenJobAction;
import org.elasticsearch.xpack.ml.action.OpenJobAction; import org.elasticsearch.xpack.ml.action.OpenJobAction;
import org.elasticsearch.xpack.ml.action.PostDataAction; import org.elasticsearch.xpack.ml.action.PostDataAction;
import org.elasticsearch.xpack.ml.action.PutJobAction; import org.elasticsearch.xpack.ml.action.PutJobAction;
import org.elasticsearch.xpack.ml.action.PutListAction; import org.elasticsearch.xpack.ml.action.PutFilterAction;
import org.elasticsearch.xpack.ml.action.PutDatafeedAction; import org.elasticsearch.xpack.ml.action.PutDatafeedAction;
import org.elasticsearch.xpack.ml.action.RevertModelSnapshotAction; import org.elasticsearch.xpack.ml.action.RevertModelSnapshotAction;
import org.elasticsearch.xpack.ml.action.StartDatafeedAction; import org.elasticsearch.xpack.ml.action.StartDatafeedAction;
@ -85,6 +85,9 @@ import org.elasticsearch.xpack.ml.job.process.normalizer.NormalizerFactory;
import org.elasticsearch.xpack.ml.job.process.normalizer.NormalizerProcessFactory; import org.elasticsearch.xpack.ml.job.process.normalizer.NormalizerProcessFactory;
import org.elasticsearch.xpack.ml.job.process.DataCountsReporter; import org.elasticsearch.xpack.ml.job.process.DataCountsReporter;
import org.elasticsearch.xpack.ml.job.usage.UsageReporter; import org.elasticsearch.xpack.ml.job.usage.UsageReporter;
import org.elasticsearch.xpack.ml.rest.filter.RestDeleteFilterAction;
import org.elasticsearch.xpack.ml.rest.filter.RestGetFiltersAction;
import org.elasticsearch.xpack.ml.rest.filter.RestPutFilterAction;
import org.elasticsearch.xpack.ml.rest.job.RestCloseJobAction; import org.elasticsearch.xpack.ml.rest.job.RestCloseJobAction;
import org.elasticsearch.xpack.ml.rest.job.RestDeleteJobAction; import org.elasticsearch.xpack.ml.rest.job.RestDeleteJobAction;
import org.elasticsearch.xpack.ml.rest.job.RestFlushJobAction; import org.elasticsearch.xpack.ml.rest.job.RestFlushJobAction;
@ -93,9 +96,6 @@ import org.elasticsearch.xpack.ml.rest.job.RestGetJobStatsAction;
import org.elasticsearch.xpack.ml.rest.job.RestOpenJobAction; import org.elasticsearch.xpack.ml.rest.job.RestOpenJobAction;
import org.elasticsearch.xpack.ml.rest.job.RestPostDataAction; import org.elasticsearch.xpack.ml.rest.job.RestPostDataAction;
import org.elasticsearch.xpack.ml.rest.job.RestPutJobAction; import org.elasticsearch.xpack.ml.rest.job.RestPutJobAction;
import org.elasticsearch.xpack.ml.rest.list.RestDeleteListAction;
import org.elasticsearch.xpack.ml.rest.list.RestGetListAction;
import org.elasticsearch.xpack.ml.rest.list.RestPutListAction;
import org.elasticsearch.xpack.ml.rest.modelsnapshots.RestDeleteModelSnapshotAction; import org.elasticsearch.xpack.ml.rest.modelsnapshots.RestDeleteModelSnapshotAction;
import org.elasticsearch.xpack.ml.rest.modelsnapshots.RestGetModelSnapshotsAction; import org.elasticsearch.xpack.ml.rest.modelsnapshots.RestGetModelSnapshotsAction;
import org.elasticsearch.xpack.ml.rest.modelsnapshots.RestRevertModelSnapshotAction; import org.elasticsearch.xpack.ml.rest.modelsnapshots.RestRevertModelSnapshotAction;
@ -195,7 +195,7 @@ public class MlPlugin extends Plugin implements ActionPlugin {
throw new ElasticsearchException("Failed to create native process factories", e); throw new ElasticsearchException("Failed to create native process factories", e);
} }
} else { } else {
autodetectProcessFactory = (jobDetails, modelSnapshot, quantiles, lists, ignoreDowntime, executorService) -> autodetectProcessFactory = (jobDetails, modelSnapshot, quantiles, filters, ignoreDowntime, executorService) ->
new BlackHoleAutodetectProcess(); new BlackHoleAutodetectProcess();
// factor of 1.0 makes renormalization a no-op // factor of 1.0 makes renormalization a no-op
normalizerProcessFactory = (jobId, quantilesState, bucketSpan, perPartitionNormalization, normalizerProcessFactory = (jobId, quantilesState, bucketSpan, perPartitionNormalization,
@ -231,9 +231,9 @@ public class MlPlugin extends Plugin implements ActionPlugin {
new RestPutJobAction(settings, restController), new RestPutJobAction(settings, restController),
new RestDeleteJobAction(settings, restController), new RestDeleteJobAction(settings, restController),
new RestOpenJobAction(settings, restController), new RestOpenJobAction(settings, restController),
new RestGetListAction(settings, restController), new RestGetFiltersAction(settings, restController),
new RestPutListAction(settings, restController), new RestPutFilterAction(settings, restController),
new RestDeleteListAction(settings, restController), new RestDeleteFilterAction(settings, restController),
new RestGetInfluencersAction(settings, restController), new RestGetInfluencersAction(settings, restController),
new RestGetRecordsAction(settings, restController), new RestGetRecordsAction(settings, restController),
new RestGetBucketsAction(settings, restController), new RestGetBucketsAction(settings, restController),
@ -268,9 +268,9 @@ public class MlPlugin extends Plugin implements ActionPlugin {
new ActionHandler<>(InternalOpenJobAction.INSTANCE, InternalOpenJobAction.TransportAction.class), new ActionHandler<>(InternalOpenJobAction.INSTANCE, InternalOpenJobAction.TransportAction.class),
new ActionHandler<>(UpdateJobStatusAction.INSTANCE, UpdateJobStatusAction.TransportAction.class), new ActionHandler<>(UpdateJobStatusAction.INSTANCE, UpdateJobStatusAction.TransportAction.class),
new ActionHandler<>(UpdateDatafeedStatusAction.INSTANCE, UpdateDatafeedStatusAction.TransportAction.class), new ActionHandler<>(UpdateDatafeedStatusAction.INSTANCE, UpdateDatafeedStatusAction.TransportAction.class),
new ActionHandler<>(GetListAction.INSTANCE, GetListAction.TransportAction.class), new ActionHandler<>(GetFiltersAction.INSTANCE, GetFiltersAction.TransportAction.class),
new ActionHandler<>(PutListAction.INSTANCE, PutListAction.TransportAction.class), new ActionHandler<>(PutFilterAction.INSTANCE, PutFilterAction.TransportAction.class),
new ActionHandler<>(DeleteListAction.INSTANCE, DeleteListAction.TransportAction.class), new ActionHandler<>(DeleteFilterAction.INSTANCE, DeleteFilterAction.TransportAction.class),
new ActionHandler<>(GetBucketsAction.INSTANCE, GetBucketsAction.TransportAction.class), new ActionHandler<>(GetBucketsAction.INSTANCE, GetBucketsAction.TransportAction.class),
new ActionHandler<>(GetInfluencersAction.INSTANCE, GetInfluencersAction.TransportAction.class), new ActionHandler<>(GetInfluencersAction.INSTANCE, GetInfluencersAction.TransportAction.class),
new ActionHandler<>(GetRecordsAction.INSTANCE, GetRecordsAction.TransportAction.class), new ActionHandler<>(GetRecordsAction.INSTANCE, GetRecordsAction.TransportAction.class),

View File

@ -34,7 +34,7 @@ import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.ml.job.config.Detector; import org.elasticsearch.xpack.ml.job.config.Detector;
import org.elasticsearch.xpack.ml.job.config.Job; import org.elasticsearch.xpack.ml.job.config.Job;
import org.elasticsearch.xpack.ml.job.metadata.MlMetadata; import org.elasticsearch.xpack.ml.job.metadata.MlMetadata;
import org.elasticsearch.xpack.ml.job.config.ListDocument; import org.elasticsearch.xpack.ml.job.config.MlFilter;
import org.elasticsearch.xpack.ml.utils.ExceptionsHelper; import org.elasticsearch.xpack.ml.utils.ExceptionsHelper;
import java.io.IOException; import java.io.IOException;
@ -44,12 +44,12 @@ import java.util.Map;
import java.util.Objects; import java.util.Objects;
public class DeleteListAction extends Action<DeleteListAction.Request, DeleteListAction.Response, DeleteListAction.RequestBuilder> { public class DeleteFilterAction extends Action<DeleteFilterAction.Request, DeleteFilterAction.Response, DeleteFilterAction.RequestBuilder> {
public static final DeleteListAction INSTANCE = new DeleteListAction(); public static final DeleteFilterAction INSTANCE = new DeleteFilterAction();
public static final String NAME = "cluster:admin/ml/list/delete"; public static final String NAME = "cluster:admin/ml/filter/delete";
private DeleteListAction() { private DeleteFilterAction() {
super(NAME); super(NAME);
} }
@ -65,20 +65,20 @@ public class DeleteListAction extends Action<DeleteListAction.Request, DeleteLis
public static class Request extends AcknowledgedRequest<Request> { public static class Request extends AcknowledgedRequest<Request> {
public static final ParseField LIST_ID = new ParseField("list_id"); public static final ParseField FILTER_ID = new ParseField("filter_id");
private String listId; private String filterId;
Request() { Request() {
} }
public Request(String listId) { public Request(String filterId) {
this.listId = ExceptionsHelper.requireNonNull(listId, LIST_ID.getPreferredName()); this.filterId = ExceptionsHelper.requireNonNull(filterId, FILTER_ID.getPreferredName());
} }
public String getListId() { public String getFilterId() {
return listId; return filterId;
} }
@Override @Override
@ -89,18 +89,18 @@ public class DeleteListAction extends Action<DeleteListAction.Request, DeleteLis
@Override @Override
public void readFrom(StreamInput in) throws IOException { public void readFrom(StreamInput in) throws IOException {
super.readFrom(in); super.readFrom(in);
listId = in.readString(); filterId = in.readString();
} }
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);
out.writeString(listId); out.writeString(filterId);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(listId); return Objects.hash(filterId);
} }
@Override @Override
@ -109,13 +109,13 @@ public class DeleteListAction extends Action<DeleteListAction.Request, DeleteLis
return false; return false;
} }
Request other = (Request) obj; Request other = (Request) obj;
return Objects.equals(listId, other.listId); return Objects.equals(filterId, other.filterId);
} }
} }
public static class RequestBuilder extends MasterNodeOperationRequestBuilder<Request, Response, RequestBuilder> { public static class RequestBuilder extends MasterNodeOperationRequestBuilder<Request, Response, RequestBuilder> {
public RequestBuilder(ElasticsearchClient client, DeleteListAction action) { public RequestBuilder(ElasticsearchClient client, DeleteFilterAction action) {
super(client, action, new Request()); super(client, action, new Request());
} }
} }
@ -153,7 +153,7 @@ public class DeleteListAction extends Action<DeleteListAction.Request, DeleteLis
ThreadPool threadPool, ActionFilters actionFilters, ThreadPool threadPool, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver, IndexNameExpressionResolver indexNameExpressionResolver,
TransportDeleteAction transportAction) { TransportDeleteAction transportAction) {
super(settings, DeleteListAction.NAME, transportService, clusterService, threadPool, actionFilters, super(settings, DeleteFilterAction.NAME, transportService, clusterService, threadPool, actionFilters,
indexNameExpressionResolver, Request::new); indexNameExpressionResolver, Request::new);
this.transportAction = transportAction; this.transportAction = transportAction;
} }
@ -171,30 +171,30 @@ public class DeleteListAction extends Action<DeleteListAction.Request, DeleteLis
@Override @Override
protected void masterOperation(Request request, ClusterState state, ActionListener<Response> listener) throws Exception { protected void masterOperation(Request request, ClusterState state, ActionListener<Response> listener) throws Exception {
final String listId = request.getListId(); final String filterId = request.getFilterId();
MlMetadata currentMlMetadata = state.metaData().custom(MlMetadata.TYPE); MlMetadata currentMlMetadata = state.metaData().custom(MlMetadata.TYPE);
Map<String, Job> jobs = currentMlMetadata.getJobs(); Map<String, Job> jobs = currentMlMetadata.getJobs();
List<String> currentlyUsedBy = new ArrayList<>(); List<String> currentlyUsedBy = new ArrayList<>();
for (Job job : jobs.values()) { for (Job job : jobs.values()) {
List<Detector> detectors = job.getAnalysisConfig().getDetectors(); List<Detector> detectors = job.getAnalysisConfig().getDetectors();
for (Detector detector : detectors) { for (Detector detector : detectors) {
if (detector.extractReferencedLists().contains(listId)) { if (detector.extractReferencedFilters().contains(filterId)) {
currentlyUsedBy.add(job.getId()); currentlyUsedBy.add(job.getId());
break; break;
} }
} }
} }
if (!currentlyUsedBy.isEmpty()) { if (!currentlyUsedBy.isEmpty()) {
throw ExceptionsHelper.conflictStatusException("Cannot delete List, currently used by jobs: " throw ExceptionsHelper.conflictStatusException("Cannot delete filter, currently used by jobs: "
+ currentlyUsedBy); + currentlyUsedBy);
} }
DeleteRequest deleteRequest = new DeleteRequest(ML_INFO_INDEX, ListDocument.TYPE.getPreferredName(), listId); DeleteRequest deleteRequest = new DeleteRequest(ML_INFO_INDEX, MlFilter.TYPE.getPreferredName(), filterId);
transportAction.execute(deleteRequest, new ActionListener<DeleteResponse>() { transportAction.execute(deleteRequest, new ActionListener<DeleteResponse>() {
@Override @Override
public void onResponse(DeleteResponse deleteResponse) { public void onResponse(DeleteResponse deleteResponse) {
if (deleteResponse.status().equals(RestStatus.NOT_FOUND)) { if (deleteResponse.status().equals(RestStatus.NOT_FOUND)) {
listener.onFailure(new ResourceNotFoundException("Could not delete list with ID [" + listId listener.onFailure(new ResourceNotFoundException("Could not delete filter with ID [" + filterId
+ "] because it does not exist")); + "] because it does not exist"));
} else { } else {
listener.onResponse(new Response(true)); listener.onResponse(new Response(true));
@ -203,8 +203,8 @@ public class DeleteListAction extends Action<DeleteListAction.Request, DeleteLis
@Override @Override
public void onFailure(Exception e) { public void onFailure(Exception e) {
logger.error("Could not delete list with ID [" + listId + "]", e); logger.error("Could not delete filter with ID [" + filterId + "]", e);
listener.onFailure(new IllegalStateException("Could not delete list with ID [" + listId + "]", e)); listener.onFailure(new IllegalStateException("Could not delete filter with ID [" + filterId + "]", e));
} }
}); });
} }

View File

@ -43,7 +43,7 @@ import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService; import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.ml.action.util.QueryPage; import org.elasticsearch.xpack.ml.action.util.QueryPage;
import org.elasticsearch.xpack.ml.action.util.PageParams; import org.elasticsearch.xpack.ml.action.util.PageParams;
import org.elasticsearch.xpack.ml.job.config.ListDocument; import org.elasticsearch.xpack.ml.job.config.MlFilter;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -54,12 +54,12 @@ import java.util.Objects;
import static org.elasticsearch.action.ValidateActions.addValidationError; import static org.elasticsearch.action.ValidateActions.addValidationError;
public class GetListAction extends Action<GetListAction.Request, GetListAction.Response, GetListAction.RequestBuilder> { public class GetFiltersAction extends Action<GetFiltersAction.Request, GetFiltersAction.Response, GetFiltersAction.RequestBuilder> {
public static final GetListAction INSTANCE = new GetListAction(); public static final GetFiltersAction INSTANCE = new GetFiltersAction();
public static final String NAME = "cluster:admin/ml/list/get"; public static final String NAME = "cluster:admin/ml/filters/get";
private GetListAction() { private GetFiltersAction() {
super(NAME); super(NAME);
} }
@ -75,22 +75,22 @@ public class GetListAction extends Action<GetListAction.Request, GetListAction.R
public static class Request extends MasterNodeReadRequest<Request> { public static class Request extends MasterNodeReadRequest<Request> {
private String listId; private String filterId;
private PageParams pageParams; private PageParams pageParams;
public Request() { public Request() {
} }
public void setListId(String listId) { public void setFilterId(String filterId) {
if (pageParams != null) { if (pageParams != null) {
throw new IllegalArgumentException("Param [" + ListDocument.ID.getPreferredName() + "] is incompatible with [" throw new IllegalArgumentException("Param [" + MlFilter.ID.getPreferredName() + "] is incompatible with ["
+ PageParams.FROM.getPreferredName()+ ", " + PageParams.SIZE.getPreferredName() + "]."); + PageParams.FROM.getPreferredName()+ ", " + PageParams.SIZE.getPreferredName() + "].");
} }
this.listId = listId; this.filterId = filterId;
} }
public String getListId() { public String getFilterId() {
return listId; return filterId;
} }
public PageParams getPageParams() { public PageParams getPageParams() {
@ -98,10 +98,10 @@ public class GetListAction extends Action<GetListAction.Request, GetListAction.R
} }
public void setPageParams(PageParams pageParams) { public void setPageParams(PageParams pageParams) {
if (listId != null) { if (filterId != null) {
throw new IllegalArgumentException("Param [" + PageParams.FROM.getPreferredName() throw new IllegalArgumentException("Param [" + PageParams.FROM.getPreferredName()
+ ", " + PageParams.SIZE.getPreferredName() + "] is incompatible with [" + ", " + PageParams.SIZE.getPreferredName() + "] is incompatible with ["
+ ListDocument.ID.getPreferredName() + "]."); + MlFilter.ID.getPreferredName() + "].");
} }
this.pageParams = pageParams; this.pageParams = pageParams;
} }
@ -109,8 +109,8 @@ public class GetListAction extends Action<GetListAction.Request, GetListAction.R
@Override @Override
public ActionRequestValidationException validate() { public ActionRequestValidationException validate() {
ActionRequestValidationException validationException = null; ActionRequestValidationException validationException = null;
if (pageParams == null && listId == null) { if (pageParams == null && filterId == null) {
validationException = addValidationError("Both [" + ListDocument.ID.getPreferredName() + "] and [" validationException = addValidationError("Both [" + MlFilter.ID.getPreferredName() + "] and ["
+ PageParams.FROM.getPreferredName() + ", " + PageParams.SIZE.getPreferredName() + "] " + PageParams.FROM.getPreferredName() + ", " + PageParams.SIZE.getPreferredName() + "] "
+ "cannot be null" , validationException); + "cannot be null" , validationException);
} }
@ -120,18 +120,18 @@ public class GetListAction extends Action<GetListAction.Request, GetListAction.R
@Override @Override
public void readFrom(StreamInput in) throws IOException { public void readFrom(StreamInput in) throws IOException {
super.readFrom(in); super.readFrom(in);
listId = in.readOptionalString(); filterId = in.readOptionalString();
} }
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);
out.writeOptionalString(listId); out.writeOptionalString(filterId);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(listId); return Objects.hash(filterId);
} }
@Override @Override
@ -143,42 +143,42 @@ public class GetListAction extends Action<GetListAction.Request, GetListAction.R
return false; return false;
} }
Request other = (Request) obj; Request other = (Request) obj;
return Objects.equals(listId, other.listId); return Objects.equals(filterId, other.filterId);
} }
} }
public static class RequestBuilder extends MasterNodeReadOperationRequestBuilder<Request, Response, RequestBuilder> { public static class RequestBuilder extends MasterNodeReadOperationRequestBuilder<Request, Response, RequestBuilder> {
public RequestBuilder(ElasticsearchClient client, GetListAction action) { public RequestBuilder(ElasticsearchClient client, GetFiltersAction action) {
super(client, action, new Request()); super(client, action, new Request());
} }
} }
public static class Response extends ActionResponse implements StatusToXContentObject { public static class Response extends ActionResponse implements StatusToXContentObject {
private QueryPage<ListDocument> lists; private QueryPage<MlFilter> filters;
public Response(QueryPage<ListDocument> lists) { public Response(QueryPage<MlFilter> filters) {
this.lists = lists; this.filters = filters;
} }
Response() { Response() {
} }
public QueryPage<ListDocument> getLists() { public QueryPage<MlFilter> getFilters() {
return lists; return filters;
} }
@Override @Override
public void readFrom(StreamInput in) throws IOException { public void readFrom(StreamInput in) throws IOException {
super.readFrom(in); super.readFrom(in);
lists = new QueryPage<>(in, ListDocument::new); filters = new QueryPage<>(in, MlFilter::new);
} }
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);
lists.writeTo(out); filters.writeTo(out);
} }
@Override @Override
@ -189,14 +189,14 @@ public class GetListAction extends Action<GetListAction.Request, GetListAction.R
@Override @Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject(); builder.startObject();
lists.doXContentBody(builder, params); filters.doXContentBody(builder, params);
builder.endObject(); builder.endObject();
return builder; return builder;
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(lists); return Objects.hash(filters);
} }
@Override @Override
@ -208,7 +208,7 @@ public class GetListAction extends Action<GetListAction.Request, GetListAction.R
return false; return false;
} }
Response other = (Response) obj; Response other = (Response) obj;
return Objects.equals(lists, other.lists); return Objects.equals(filters, other.filters);
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@ -240,7 +240,7 @@ public class GetListAction extends Action<GetListAction.Request, GetListAction.R
ThreadPool threadPool, ActionFilters actionFilters, ThreadPool threadPool, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver, IndexNameExpressionResolver indexNameExpressionResolver,
TransportGetAction transportGetAction, TransportSearchAction transportSearchAction) { TransportGetAction transportGetAction, TransportSearchAction transportSearchAction) {
super(settings, GetListAction.NAME, transportService, clusterService, threadPool, actionFilters, super(settings, GetFiltersAction.NAME, transportService, clusterService, threadPool, actionFilters,
indexNameExpressionResolver, Request::new); indexNameExpressionResolver, Request::new);
this.transportGetAction = transportGetAction; this.transportGetAction = transportGetAction;
this.transportSearchAction = transportSearchAction; this.transportSearchAction = transportSearchAction;
@ -258,13 +258,13 @@ public class GetListAction extends Action<GetListAction.Request, GetListAction.R
@Override @Override
protected void masterOperation(Request request, ClusterState state, ActionListener<Response> listener) throws Exception { protected void masterOperation(Request request, ClusterState state, ActionListener<Response> listener) throws Exception {
final String listId = request.getListId(); final String filterId = request.getFilterId();
if (!Strings.isNullOrEmpty(listId)) { if (!Strings.isNullOrEmpty(filterId)) {
getList(listId, listener); getFilter(filterId, listener);
} else if (request.getPageParams() != null) { } else if (request.getPageParams() != null) {
getLists(request.getPageParams(), listener); getFilters(request.getPageParams(), listener);
} else { } else {
throw new IllegalStateException("Both listId and pageParams are null"); throw new IllegalStateException("Both filterId and pageParams are null");
} }
} }
@ -273,25 +273,25 @@ public class GetListAction extends Action<GetListAction.Request, GetListAction.R
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ); return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_READ);
} }
private void getList(String listId, ActionListener<Response> listener) { private void getFilter(String filterId, ActionListener<Response> listener) {
GetRequest getRequest = new GetRequest(ML_INFO_INDEX, ListDocument.TYPE.getPreferredName(), listId); GetRequest getRequest = new GetRequest(ML_INFO_INDEX, MlFilter.TYPE.getPreferredName(), filterId);
transportGetAction.execute(getRequest, new ActionListener<GetResponse>() { transportGetAction.execute(getRequest, new ActionListener<GetResponse>() {
@Override @Override
public void onResponse(GetResponse getDocResponse) { public void onResponse(GetResponse getDocResponse) {
try { try {
QueryPage<ListDocument> responseBody; QueryPage<MlFilter> responseBody;
if (getDocResponse.isExists()) { if (getDocResponse.isExists()) {
BytesReference docSource = getDocResponse.getSourceAsBytesRef(); BytesReference docSource = getDocResponse.getSourceAsBytesRef();
XContentParser parser = XContentParser parser =
XContentFactory.xContent(docSource).createParser(NamedXContentRegistry.EMPTY, docSource); XContentFactory.xContent(docSource).createParser(NamedXContentRegistry.EMPTY, docSource);
ListDocument listDocument = ListDocument.PARSER.apply(parser, null); MlFilter filter = MlFilter.PARSER.apply(parser, null);
responseBody = new QueryPage<>(Collections.singletonList(listDocument), 1, ListDocument.RESULTS_FIELD); responseBody = new QueryPage<>(Collections.singletonList(filter), 1, MlFilter.RESULTS_FIELD);
Response listResponse = new Response(responseBody); Response filterResponse = new Response(responseBody);
listener.onResponse(listResponse); listener.onResponse(filterResponse);
} else { } else {
this.onFailure(QueryPage.emptyQueryPage(ListDocument.RESULTS_FIELD)); this.onFailure(QueryPage.emptyQueryPage(MlFilter.RESULTS_FIELD));
} }
} catch (Exception e) { } catch (Exception e) {
@ -306,29 +306,29 @@ public class GetListAction extends Action<GetListAction.Request, GetListAction.R
}); });
} }
private void getLists(PageParams pageParams, ActionListener<Response> listener) { private void getFilters(PageParams pageParams, ActionListener<Response> listener) {
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder() SearchSourceBuilder sourceBuilder = new SearchSourceBuilder()
.from(pageParams.getFrom()) .from(pageParams.getFrom())
.size(pageParams.getSize()); .size(pageParams.getSize());
SearchRequest searchRequest = new SearchRequest(new String[]{ML_INFO_INDEX}, sourceBuilder) SearchRequest searchRequest = new SearchRequest(new String[]{ML_INFO_INDEX}, sourceBuilder)
.types(ListDocument.TYPE.getPreferredName()); .types(MlFilter.TYPE.getPreferredName());
transportSearchAction.execute(searchRequest, new ActionListener<SearchResponse>() { transportSearchAction.execute(searchRequest, new ActionListener<SearchResponse>() {
@Override @Override
public void onResponse(SearchResponse response) { public void onResponse(SearchResponse response) {
try { try {
List<ListDocument> docs = new ArrayList<>(); List<MlFilter> docs = new ArrayList<>();
for (SearchHit hit : response.getHits().getHits()) { for (SearchHit hit : response.getHits().getHits()) {
BytesReference docSource = hit.sourceRef(); BytesReference docSource = hit.sourceRef();
XContentParser parser = XContentParser parser =
XContentFactory.xContent(docSource).createParser(NamedXContentRegistry.EMPTY, docSource); XContentFactory.xContent(docSource).createParser(NamedXContentRegistry.EMPTY, docSource);
docs.add(ListDocument.PARSER.apply(parser, null)); docs.add(MlFilter.PARSER.apply(parser, null));
} }
Response listResponse = new Response(new QueryPage<>(docs, docs.size(), ListDocument.RESULTS_FIELD)); Response filterResponse = new Response(new QueryPage<>(docs, docs.size(), MlFilter.RESULTS_FIELD));
listener.onResponse(listResponse); listener.onResponse(filterResponse);
} catch (Exception e) { } catch (Exception e) {
this.onFailure(e); this.onFailure(e);

View File

@ -33,19 +33,19 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.TransportService; import org.elasticsearch.transport.TransportService;
import org.elasticsearch.xpack.ml.job.config.ListDocument; import org.elasticsearch.xpack.ml.job.config.MlFilter;
import org.elasticsearch.xpack.ml.utils.ExceptionsHelper; import org.elasticsearch.xpack.ml.utils.ExceptionsHelper;
import java.io.IOException; import java.io.IOException;
import java.util.Objects; import java.util.Objects;
public class PutListAction extends Action<PutListAction.Request, PutListAction.Response, PutListAction.RequestBuilder> { public class PutFilterAction extends Action<PutFilterAction.Request, PutFilterAction.Response, PutFilterAction.RequestBuilder> {
public static final PutListAction INSTANCE = new PutListAction(); public static final PutFilterAction INSTANCE = new PutFilterAction();
public static final String NAME = "cluster:admin/ml/list/put"; public static final String NAME = "cluster:admin/ml/filter/put";
private PutListAction() { private PutFilterAction() {
super(NAME); super(NAME);
} }
@ -62,22 +62,22 @@ public class PutListAction extends Action<PutListAction.Request, PutListAction.R
public static class Request extends MasterNodeReadRequest<Request> implements ToXContent { public static class Request extends MasterNodeReadRequest<Request> implements ToXContent {
public static Request parseRequest(XContentParser parser) { public static Request parseRequest(XContentParser parser) {
ListDocument listDocument = ListDocument.PARSER.apply(parser, null); MlFilter filter = MlFilter.PARSER.apply(parser, null);
return new Request(listDocument); return new Request(filter);
} }
private ListDocument listDocument; private MlFilter filter;
Request() { Request() {
} }
public Request(ListDocument listDocument) { public Request(MlFilter filter) {
this.listDocument = ExceptionsHelper.requireNonNull(listDocument, "list_document"); this.filter = ExceptionsHelper.requireNonNull(filter, "filter");
} }
public ListDocument getListDocument() { public MlFilter getFilter() {
return this.listDocument; return this.filter;
} }
@Override @Override
@ -88,24 +88,24 @@ public class PutListAction extends Action<PutListAction.Request, PutListAction.R
@Override @Override
public void readFrom(StreamInput in) throws IOException { public void readFrom(StreamInput in) throws IOException {
super.readFrom(in); super.readFrom(in);
listDocument = new ListDocument(in); filter = new MlFilter(in);
} }
@Override @Override
public void writeTo(StreamOutput out) throws IOException { public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out); super.writeTo(out);
listDocument.writeTo(out); filter.writeTo(out);
} }
@Override @Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
listDocument.toXContent(builder, params); filter.toXContent(builder, params);
return builder; return builder;
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(listDocument); return Objects.hash(filter);
} }
@Override @Override
@ -117,13 +117,13 @@ public class PutListAction extends Action<PutListAction.Request, PutListAction.R
return false; return false;
} }
Request other = (Request) obj; Request other = (Request) obj;
return Objects.equals(listDocument, other.listDocument); return Objects.equals(filter, other.filter);
} }
} }
public static class RequestBuilder extends MasterNodeOperationRequestBuilder<Request, Response, RequestBuilder> { public static class RequestBuilder extends MasterNodeOperationRequestBuilder<Request, Response, RequestBuilder> {
public RequestBuilder(ElasticsearchClient client, PutListAction action) { public RequestBuilder(ElasticsearchClient client, PutFilterAction action) {
super(client, action, new Request()); super(client, action, new Request());
} }
} }
@ -160,7 +160,7 @@ public class PutListAction extends Action<PutListAction.Request, PutListAction.R
ThreadPool threadPool, ActionFilters actionFilters, ThreadPool threadPool, ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver, IndexNameExpressionResolver indexNameExpressionResolver,
TransportIndexAction transportIndexAction) { TransportIndexAction transportIndexAction) {
super(settings, PutListAction.NAME, transportService, clusterService, threadPool, actionFilters, super(settings, PutFilterAction.NAME, transportService, clusterService, threadPool, actionFilters,
indexNameExpressionResolver, Request::new); indexNameExpressionResolver, Request::new);
this.transportIndexAction = transportIndexAction; this.transportIndexAction = transportIndexAction;
} }
@ -177,11 +177,11 @@ public class PutListAction extends Action<PutListAction.Request, PutListAction.R
@Override @Override
protected void masterOperation(Request request, ClusterState state, ActionListener<Response> listener) throws Exception { protected void masterOperation(Request request, ClusterState state, ActionListener<Response> listener) throws Exception {
ListDocument listDocument = request.getListDocument(); MlFilter filter = request.getFilter();
final String listId = listDocument.getId(); final String filterId = filter.getId();
IndexRequest indexRequest = new IndexRequest(ML_INFO_INDEX, ListDocument.TYPE.getPreferredName(), listId); IndexRequest indexRequest = new IndexRequest(ML_INFO_INDEX, MlFilter.TYPE.getPreferredName(), filterId);
XContentBuilder builder = XContentFactory.jsonBuilder(); XContentBuilder builder = XContentFactory.jsonBuilder();
indexRequest.source(listDocument.toXContent(builder, ToXContent.EMPTY_PARAMS)); indexRequest.source(filter.toXContent(builder, ToXContent.EMPTY_PARAMS));
transportIndexAction.execute(indexRequest, new ActionListener<IndexResponse>() { transportIndexAction.execute(indexRequest, new ActionListener<IndexResponse>() {
@Override @Override
public void onResponse(IndexResponse indexResponse) { public void onResponse(IndexResponse indexResponse) {
@ -190,8 +190,8 @@ public class PutListAction extends Action<PutListAction.Request, PutListAction.R
@Override @Override
public void onFailure(Exception e) { public void onFailure(Exception e) {
logger.error("Could not create list with ID [" + listId + "]", e); logger.error("Could not create filter with ID [" + filterId + "]", e);
throw new ResourceNotFoundException("Could not create list with ID [" + listId + "]", e); throw new ResourceNotFoundException("Could not create filter with ID [" + filterId + "]", e);
} }
}); });
} }

View File

@ -279,8 +279,8 @@ public class AnalysisConfig extends ToXContentToBytes implements Writeable {
return termFields; return termFields;
} }
public Set<String> extractReferencedLists() { public Set<String> extractReferencedFilters() {
return detectors.stream().map(Detector::extractReferencedLists) return detectors.stream().map(Detector::extractReferencedFilters)
.flatMap(Set::stream).collect(Collectors.toSet()); .flatMap(Set::stream).collect(Collectors.toSet());
} }

View File

@ -141,8 +141,8 @@ public class DetectionRule extends ToXContentToBytes implements Writeable {
return ruleConditions; return ruleConditions;
} }
public Set<String> extractReferencedLists() { public Set<String> extractReferencedFilters() {
return ruleConditions.stream().map(RuleCondition::getValueList).filter(Objects::nonNull).collect(Collectors.toSet()); return ruleConditions.stream().map(RuleCondition::getValueFilter).filter(Objects::nonNull).collect(Collectors.toSet());
} }
@Override @Override

View File

@ -473,9 +473,9 @@ public class Detector extends ToXContentToBytes implements Writeable {
return analysisFields.stream().filter(item -> item != null).collect(Collectors.toList()); return analysisFields.stream().filter(item -> item != null).collect(Collectors.toList());
} }
public Set<String> extractReferencedLists() { public Set<String> extractReferencedFilters() {
return detectorRules == null ? Collections.emptySet() return detectorRules == null ? Collections.emptySet()
: detectorRules.stream().map(DetectionRule::extractReferencedLists) : detectorRules.stream().map(DetectionRule::extractReferencedFilters)
.flatMap(Set::stream).collect(Collectors.toSet()); .flatMap(Set::stream).collect(Collectors.toSet());
} }

View File

@ -19,17 +19,17 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
public class ListDocument extends ToXContentToBytes implements Writeable { public class MlFilter extends ToXContentToBytes implements Writeable {
public static final ParseField TYPE = new ParseField("list"); public static final ParseField TYPE = new ParseField("filter");
public static final ParseField ID = new ParseField("id"); public static final ParseField ID = new ParseField("id");
public static final ParseField ITEMS = new ParseField("items"); public static final ParseField ITEMS = new ParseField("items");
// For QueryPage // For QueryPage
public static final ParseField RESULTS_FIELD = new ParseField("lists"); public static final ParseField RESULTS_FIELD = new ParseField("filters");
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static final ConstructingObjectParser<ListDocument, Void> PARSER = new ConstructingObjectParser<>( public static final ConstructingObjectParser<MlFilter, Void> PARSER = new ConstructingObjectParser<>(
TYPE.getPreferredName(), a -> new ListDocument((String) a[0], (List<String>) a[1])); TYPE.getPreferredName(), a -> new MlFilter((String) a[0], (List<String>) a[1]));
static { static {
PARSER.declareString(ConstructingObjectParser.constructorArg(), ID); PARSER.declareString(ConstructingObjectParser.constructorArg(), ID);
@ -39,12 +39,12 @@ public class ListDocument extends ToXContentToBytes implements Writeable {
private final String id; private final String id;
private final List<String> items; private final List<String> items;
public ListDocument(String id, List<String> items) { public MlFilter(String id, List<String> items) {
this.id = Objects.requireNonNull(id, ID.getPreferredName() + " must not be null"); this.id = Objects.requireNonNull(id, ID.getPreferredName() + " must not be null");
this.items = Objects.requireNonNull(items, ITEMS.getPreferredName() + " must not be null"); this.items = Objects.requireNonNull(items, ITEMS.getPreferredName() + " must not be null");
} }
public ListDocument(StreamInput in) throws IOException { public MlFilter(StreamInput in) throws IOException {
id = in.readString(); id = in.readString();
items = Arrays.asList(in.readStringArray()); items = Arrays.asList(in.readStringArray());
} }
@ -78,11 +78,11 @@ public class ListDocument extends ToXContentToBytes implements Writeable {
return true; return true;
} }
if (!(obj instanceof ListDocument)) { if (!(obj instanceof MlFilter)) {
return false; return false;
} }
ListDocument other = (ListDocument) obj; MlFilter other = (MlFilter) obj;
return id.equals(other.id) && items.equals(other.items); return id.equals(other.id) && items.equals(other.items);
} }

View File

@ -26,7 +26,7 @@ public class RuleCondition extends ToXContentToBytes implements Writeable {
public static final ParseField RULE_CONDITION_FIELD = new ParseField("rule_condition"); public static final ParseField RULE_CONDITION_FIELD = new ParseField("rule_condition");
public static final ParseField FIELD_NAME_FIELD = new ParseField("field_name"); public static final ParseField FIELD_NAME_FIELD = new ParseField("field_name");
public static final ParseField FIELD_VALUE_FIELD = new ParseField("field_value"); public static final ParseField FIELD_VALUE_FIELD = new ParseField("field_value");
public static final ParseField VALUE_LIST_FIELD = new ParseField("value_list"); public static final ParseField VALUE_FILTER_FIELD = new ParseField("value_filter");
public static final ConstructingObjectParser<RuleCondition, Void> PARSER = public static final ConstructingObjectParser<RuleCondition, Void> PARSER =
new ConstructingObjectParser<>(RULE_CONDITION_FIELD.getPreferredName(), new ConstructingObjectParser<>(RULE_CONDITION_FIELD.getPreferredName(),
@ -42,21 +42,21 @@ public class RuleCondition extends ToXContentToBytes implements Writeable {
PARSER.declareStringOrNull(ConstructingObjectParser.optionalConstructorArg(), FIELD_NAME_FIELD); PARSER.declareStringOrNull(ConstructingObjectParser.optionalConstructorArg(), FIELD_NAME_FIELD);
PARSER.declareStringOrNull(ConstructingObjectParser.optionalConstructorArg(), FIELD_VALUE_FIELD); PARSER.declareStringOrNull(ConstructingObjectParser.optionalConstructorArg(), FIELD_VALUE_FIELD);
PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), Condition.PARSER, Condition.CONDITION_FIELD); PARSER.declareObject(ConstructingObjectParser.optionalConstructorArg(), Condition.PARSER, Condition.CONDITION_FIELD);
PARSER.declareStringOrNull(ConstructingObjectParser.optionalConstructorArg(), VALUE_LIST_FIELD); PARSER.declareStringOrNull(ConstructingObjectParser.optionalConstructorArg(), VALUE_FILTER_FIELD);
} }
private final RuleConditionType conditionType; private final RuleConditionType conditionType;
private final String fieldName; private final String fieldName;
private final String fieldValue; private final String fieldValue;
private final Condition condition; private final Condition condition;
private final String valueList; private final String valueFilter;
public RuleCondition(StreamInput in) throws IOException { public RuleCondition(StreamInput in) throws IOException {
conditionType = RuleConditionType.readFromStream(in); conditionType = RuleConditionType.readFromStream(in);
condition = in.readOptionalWriteable(Condition::new); condition = in.readOptionalWriteable(Condition::new);
fieldName = in.readOptionalString(); fieldName = in.readOptionalString();
fieldValue = in.readOptionalString(); fieldValue = in.readOptionalString();
valueList = in.readOptionalString(); valueFilter = in.readOptionalString();
} }
@Override @Override
@ -65,15 +65,15 @@ public class RuleCondition extends ToXContentToBytes implements Writeable {
out.writeOptionalWriteable(condition); out.writeOptionalWriteable(condition);
out.writeOptionalString(fieldName); out.writeOptionalString(fieldName);
out.writeOptionalString(fieldValue); out.writeOptionalString(fieldValue);
out.writeOptionalString(valueList); out.writeOptionalString(valueFilter);
} }
public RuleCondition(RuleConditionType conditionType, String fieldName, String fieldValue, Condition condition, String valueList) { public RuleCondition(RuleConditionType conditionType, String fieldName, String fieldValue, Condition condition, String valueFilter) {
this.conditionType = conditionType; this.conditionType = conditionType;
this.fieldName = fieldName; this.fieldName = fieldName;
this.fieldValue = fieldValue; this.fieldValue = fieldValue;
this.condition = condition; this.condition = condition;
this.valueList = valueList; this.valueFilter = valueFilter;
verifyFieldsBoundToType(this); verifyFieldsBoundToType(this);
verifyFieldValueRequiresFieldName(this); verifyFieldValueRequiresFieldName(this);
@ -84,7 +84,7 @@ public class RuleCondition extends ToXContentToBytes implements Writeable {
this.fieldName = ruleCondition.fieldName; this.fieldName = ruleCondition.fieldName;
this.fieldValue = ruleCondition.fieldValue; this.fieldValue = ruleCondition.fieldValue;
this.condition = ruleCondition.condition; this.condition = ruleCondition.condition;
this.valueList = ruleCondition.valueList; this.valueFilter = ruleCondition.valueFilter;
} }
@Override @Override
@ -100,8 +100,8 @@ public class RuleCondition extends ToXContentToBytes implements Writeable {
if (fieldValue != null) { if (fieldValue != null) {
builder.field(FIELD_VALUE_FIELD.getPreferredName(), fieldValue); builder.field(FIELD_VALUE_FIELD.getPreferredName(), fieldValue);
} }
if (valueList != null) { if (valueFilter != null) {
builder.field(VALUE_LIST_FIELD.getPreferredName(), valueList); builder.field(VALUE_FILTER_FIELD.getPreferredName(), valueFilter);
} }
builder.endObject(); builder.endObject();
return builder; return builder;
@ -134,11 +134,11 @@ public class RuleCondition extends ToXContentToBytes implements Writeable {
} }
/** /**
* The unique identifier of a list. Required when the rule type is * The unique identifier of a filter. Required when the rule type is
* categorical. Should be null for all other types. * categorical. Should be null for all other types.
*/ */
public String getValueList() { public String getValueFilter() {
return valueList; return valueFilter;
} }
@Override @Override
@ -154,16 +154,16 @@ public class RuleCondition extends ToXContentToBytes implements Writeable {
RuleCondition other = (RuleCondition) obj; RuleCondition other = (RuleCondition) obj;
return Objects.equals(conditionType, other.conditionType) && Objects.equals(fieldName, other.fieldName) return Objects.equals(conditionType, other.conditionType) && Objects.equals(fieldName, other.fieldName)
&& Objects.equals(fieldValue, other.fieldValue) && Objects.equals(condition, other.condition) && Objects.equals(fieldValue, other.fieldValue) && Objects.equals(condition, other.condition)
&& Objects.equals(valueList, other.valueList); && Objects.equals(valueFilter, other.valueFilter);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(conditionType, fieldName, fieldValue, condition, valueList); return Objects.hash(conditionType, fieldName, fieldValue, condition, valueFilter);
} }
public static RuleCondition createCategorical(String fieldName, String valueList) { public static RuleCondition createCategorical(String fieldName, String valueFilter) {
return new RuleCondition(RuleConditionType.CATEGORICAL, fieldName, null, null, valueList); return new RuleCondition(RuleConditionType.CATEGORICAL, fieldName, null, null, valueFilter);
} }
private static void verifyFieldsBoundToType(RuleCondition ruleCondition) throws ElasticsearchParseException { private static void verifyFieldsBoundToType(RuleCondition ruleCondition) throws ElasticsearchParseException {
@ -184,7 +184,7 @@ public class RuleCondition extends ToXContentToBytes implements Writeable {
private static void verifyCategorical(RuleCondition ruleCondition) throws ElasticsearchParseException { private static void verifyCategorical(RuleCondition ruleCondition) throws ElasticsearchParseException {
checkCategoricalHasNoField(Condition.CONDITION_FIELD.getPreferredName(), ruleCondition.getCondition()); checkCategoricalHasNoField(Condition.CONDITION_FIELD.getPreferredName(), ruleCondition.getCondition());
checkCategoricalHasNoField(RuleCondition.FIELD_VALUE_FIELD.getPreferredName(), ruleCondition.getFieldValue()); checkCategoricalHasNoField(RuleCondition.FIELD_VALUE_FIELD.getPreferredName(), ruleCondition.getFieldValue());
checkCategoricalHasField(RuleCondition.VALUE_LIST_FIELD.getPreferredName(), ruleCondition.getValueList()); checkCategoricalHasField(RuleCondition.VALUE_FILTER_FIELD.getPreferredName(), ruleCondition.getValueFilter());
} }
private static void checkCategoricalHasNoField(String fieldName, Object fieldValue) throws ElasticsearchParseException { private static void checkCategoricalHasNoField(String fieldName, Object fieldValue) throws ElasticsearchParseException {
@ -202,7 +202,7 @@ public class RuleCondition extends ToXContentToBytes implements Writeable {
} }
private static void verifyNumerical(RuleCondition ruleCondition) throws ElasticsearchParseException { private static void verifyNumerical(RuleCondition ruleCondition) throws ElasticsearchParseException {
checkNumericalHasNoField(RuleCondition.VALUE_LIST_FIELD.getPreferredName(), ruleCondition.getValueList()); checkNumericalHasNoField(RuleCondition.VALUE_FILTER_FIELD.getPreferredName(), ruleCondition.getValueFilter());
checkNumericalHasField(Condition.CONDITION_FIELD.getPreferredName(), ruleCondition.getCondition()); checkNumericalHasField(Condition.CONDITION_FIELD.getPreferredName(), ruleCondition.getCondition());
if (ruleCondition.getFieldName() != null && ruleCondition.getFieldValue() == null) { if (ruleCondition.getFieldName() != null && ruleCondition.getFieldValue() == null) {
String msg = Messages.getMessage(Messages.JOB_CONFIG_DETECTION_RULE_CONDITION_NUMERICAL_WITH_FIELD_NAME_REQUIRES_FIELD_VALUE); String msg = Messages.getMessage(Messages.JOB_CONFIG_DETECTION_RULE_CONDITION_NUMERICAL_WITH_FIELD_NAME_REQUIRES_FIELD_VALUE);

View File

@ -207,9 +207,6 @@ public final class Messages {
public static final String JSON_DETECTOR_CONFIG_MAPPING = "json.detector.config.mapping.error"; public static final String JSON_DETECTOR_CONFIG_MAPPING = "json.detector.config.mapping.error";
public static final String JSON_DETECTOR_CONFIG_PARSE = "json.detector.config.parse.error"; public static final String JSON_DETECTOR_CONFIG_PARSE = "json.detector.config.parse.error";
public static final String JSON_LIST_DOCUMENT_MAPPING_ERROR = "json.list.document.mapping.error";
public static final String JSON_LIST_DOCUMENT_PARSE_ERROR = "json.list.document.parse.error";
public static final String JSON_TRANSFORM_CONFIG_MAPPING = "json.transform.config.mapping.error"; public static final String JSON_TRANSFORM_CONFIG_MAPPING = "json.transform.config.mapping.error";
public static final String JSON_TRANSFORM_CONFIG_PARSE = "json.transform.config.parse.error"; public static final String JSON_TRANSFORM_CONFIG_PARSE = "json.transform.config.parse.error";

View File

@ -69,7 +69,7 @@ import org.elasticsearch.xpack.ml.job.results.ModelDebugOutput;
import org.elasticsearch.xpack.ml.job.results.PerPartitionMaxProbabilities; import org.elasticsearch.xpack.ml.job.results.PerPartitionMaxProbabilities;
import org.elasticsearch.xpack.ml.job.results.Result; import org.elasticsearch.xpack.ml.job.results.Result;
import org.elasticsearch.xpack.ml.job.usage.Usage; import org.elasticsearch.xpack.ml.job.usage.Usage;
import org.elasticsearch.xpack.ml.job.config.ListDocument; import org.elasticsearch.xpack.ml.job.config.MlFilter;
import org.elasticsearch.xpack.ml.utils.ExceptionsHelper; import org.elasticsearch.xpack.ml.utils.ExceptionsHelper;
import java.io.IOException; import java.io.IOException;
@ -1057,12 +1057,12 @@ public class JobProvider {
} }
/** /**
* Retrieves the list with the given {@code listId} from the datastore. * Retrieves the filter with the given {@code filterId} from the datastore.
* *
* @param ids the id of the requested list * @param ids the id of the requested filter
*/ */
public void getLists(Consumer<Set<ListDocument>> handler, Consumer<Exception> errorHandler, String... ids) { public void getFilters(Consumer<Set<MlFilter>> handler, Consumer<Exception> errorHandler, String... ids) {
mget(ML_INFO_INDEX, ListDocument.TYPE.getPreferredName(), ids, handler, errorHandler, ListDocument.PARSER); mget(ML_INFO_INDEX, MlFilter.TYPE.getPreferredName(), ids, handler, errorHandler, MlFilter.PARSER);
} }
/** /**

View File

@ -18,7 +18,7 @@ import org.elasticsearch.xpack.ml.job.process.autodetect.writer.AnalysisLimitsWr
import org.elasticsearch.xpack.ml.job.process.autodetect.writer.FieldConfigWriter; import org.elasticsearch.xpack.ml.job.process.autodetect.writer.FieldConfigWriter;
import org.elasticsearch.xpack.ml.job.process.autodetect.writer.ModelDebugConfigWriter; import org.elasticsearch.xpack.ml.job.process.autodetect.writer.ModelDebugConfigWriter;
import org.elasticsearch.xpack.ml.job.process.autodetect.state.Quantiles; import org.elasticsearch.xpack.ml.job.process.autodetect.state.Quantiles;
import org.elasticsearch.xpack.ml.job.config.ListDocument; import org.elasticsearch.xpack.ml.job.config.MlFilter;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
@ -44,7 +44,7 @@ public class AutodetectBuilder {
private List<Path> filesToDelete; private List<Path> filesToDelete;
private Logger logger; private Logger logger;
private boolean ignoreDowntime; private boolean ignoreDowntime;
private Set<ListDocument> referencedLists; private Set<MlFilter> referencedFilters;
private Quantiles quantiles; private Quantiles quantiles;
private Environment env; private Environment env;
private Settings settings; private Settings settings;
@ -69,7 +69,7 @@ public class AutodetectBuilder {
this.filesToDelete = Objects.requireNonNull(filesToDelete); this.filesToDelete = Objects.requireNonNull(filesToDelete);
this.logger = Objects.requireNonNull(logger); this.logger = Objects.requireNonNull(logger);
ignoreDowntime = false; ignoreDowntime = false;
referencedLists = new HashSet<>(); referencedFilters = new HashSet<>();
} }
/** /**
@ -83,8 +83,8 @@ public class AutodetectBuilder {
return this; return this;
} }
public AutodetectBuilder referencedLists(Set<ListDocument> lists) { public AutodetectBuilder referencedFilters(Set<MlFilter> filters) {
referencedLists = lists; referencedFilters = filters;
return this; return this;
} }
@ -174,7 +174,7 @@ public class AutodetectBuilder {
try (OutputStreamWriter osw = new OutputStreamWriter( try (OutputStreamWriter osw = new OutputStreamWriter(
Files.newOutputStream(fieldConfigFile), Files.newOutputStream(fieldConfigFile),
StandardCharsets.UTF_8)) { StandardCharsets.UTF_8)) {
new FieldConfigWriter(job.getAnalysisConfig(), referencedLists, osw, logger).write(); new FieldConfigWriter(job.getAnalysisConfig(), referencedFilters, osw, logger).write();
} }
String fieldConfig = FIELD_CONFIG_ARG + fieldConfigFile.toString(); String fieldConfig = FIELD_CONFIG_ARG + fieldConfigFile.toString();

View File

@ -8,7 +8,7 @@ package org.elasticsearch.xpack.ml.job.process.autodetect;
import org.elasticsearch.xpack.ml.job.config.Job; import org.elasticsearch.xpack.ml.job.config.Job;
import org.elasticsearch.xpack.ml.job.process.autodetect.state.ModelSnapshot; import org.elasticsearch.xpack.ml.job.process.autodetect.state.ModelSnapshot;
import org.elasticsearch.xpack.ml.job.process.autodetect.state.Quantiles; import org.elasticsearch.xpack.ml.job.process.autodetect.state.Quantiles;
import org.elasticsearch.xpack.ml.job.config.ListDocument; import org.elasticsearch.xpack.ml.job.config.MlFilter;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
@ -24,11 +24,11 @@ public interface AutodetectProcessFactory {
* @param job Job configuration for the analysis process * @param job Job configuration for the analysis process
* @param modelSnapshot The model snapshot to restore from * @param modelSnapshot The model snapshot to restore from
* @param quantiles The quantiles to push to the native process * @param quantiles The quantiles to push to the native process
* @param list The lists to push to the native process * @param filters The filters to push to the native process
* @param ignoreDowntime Should gaps in data be treated as anomalous or as a maintenance window after a job re-start * @param ignoreDowntime Should gaps in data be treated as anomalous or as a maintenance window after a job re-start
* @param executorService Executor service used to start the async tasks a job needs to operate the analytical process * @param executorService Executor service used to start the async tasks a job needs to operate the analytical process
* @return The process * @return The process
*/ */
AutodetectProcess createAutodetectProcess(Job job, ModelSnapshot modelSnapshot, Quantiles quantiles, Set<ListDocument> list, AutodetectProcess createAutodetectProcess(Job job, ModelSnapshot modelSnapshot, Quantiles quantiles, Set<MlFilter> filters,
boolean ignoreDowntime, ExecutorService executorService); boolean ignoreDowntime, ExecutorService executorService);
} }

View File

@ -19,7 +19,7 @@ import org.elasticsearch.xpack.ml.action.UpdateJobStatusAction;
import org.elasticsearch.xpack.ml.job.JobManager; import org.elasticsearch.xpack.ml.job.JobManager;
import org.elasticsearch.xpack.ml.job.config.Job; import org.elasticsearch.xpack.ml.job.config.Job;
import org.elasticsearch.xpack.ml.job.config.JobStatus; import org.elasticsearch.xpack.ml.job.config.JobStatus;
import org.elasticsearch.xpack.ml.job.config.ListDocument; import org.elasticsearch.xpack.ml.job.config.MlFilter;
import org.elasticsearch.xpack.ml.job.metadata.Allocation; import org.elasticsearch.xpack.ml.job.metadata.Allocation;
import org.elasticsearch.xpack.ml.job.persistence.JobDataCountsPersister; import org.elasticsearch.xpack.ml.job.persistence.JobDataCountsPersister;
import org.elasticsearch.xpack.ml.job.persistence.JobProvider; import org.elasticsearch.xpack.ml.job.persistence.JobProvider;
@ -189,9 +189,9 @@ public class AutodetectProcessManager extends AbstractComponent {
} }
public void openJob(String jobId, boolean ignoreDowntime, Consumer<Exception> handler) { public void openJob(String jobId, boolean ignoreDowntime, Consumer<Exception> handler) {
gatherRequiredInformation(jobId, (modelSnapshot, quantiles, lists) -> { gatherRequiredInformation(jobId, (modelSnapshot, quantiles, filters) -> {
autoDetectCommunicatorByJob.computeIfAbsent(jobId, id -> { autoDetectCommunicatorByJob.computeIfAbsent(jobId, id -> {
AutodetectCommunicator communicator = create(id, modelSnapshot, quantiles, lists, ignoreDowntime, handler); AutodetectCommunicator communicator = create(id, modelSnapshot, quantiles, filters, ignoreDowntime, handler);
try { try {
communicator.writeJobInputHeader(); communicator.writeJobInputHeader();
} catch (IOException ioe) { } catch (IOException ioe) {
@ -210,19 +210,19 @@ public class AutodetectProcessManager extends AbstractComponent {
jobProvider.modelSnapshots(jobId, 0, 1, page -> { jobProvider.modelSnapshots(jobId, 0, 1, page -> {
ModelSnapshot modelSnapshot = page.results().isEmpty() ? null : page.results().get(1); ModelSnapshot modelSnapshot = page.results().isEmpty() ? null : page.results().get(1);
jobProvider.getQuantiles(jobId, quantiles -> { jobProvider.getQuantiles(jobId, quantiles -> {
String[] ids = job.getAnalysisConfig().extractReferencedLists().toArray(new String[0]); String[] ids = job.getAnalysisConfig().extractReferencedFilters().toArray(new String[0]);
jobProvider.getLists(listDocument -> handler.accept(modelSnapshot, quantiles, listDocument), errorHandler, ids); jobProvider.getFilters(filterDocument -> handler.accept(modelSnapshot, quantiles, filterDocument), errorHandler, ids);
}, errorHandler); }, errorHandler);
}, errorHandler); }, errorHandler);
} }
interface TriConsumer { interface TriConsumer {
void accept(ModelSnapshot modelSnapshot, Quantiles quantiles, Set<ListDocument> lists); void accept(ModelSnapshot modelSnapshot, Quantiles quantiles, Set<MlFilter> filters);
} }
AutodetectCommunicator create(String jobId, ModelSnapshot modelSnapshot, Quantiles quantiles, Set<ListDocument> lists, AutodetectCommunicator create(String jobId, ModelSnapshot modelSnapshot, Quantiles quantiles, Set<MlFilter> filters,
boolean ignoreDowntime, Consumer<Exception> handler) { boolean ignoreDowntime, Consumer<Exception> handler) {
if (autoDetectCommunicatorByJob.size() == maxAllowedRunningJobs) { if (autoDetectCommunicatorByJob.size() == maxAllowedRunningJobs) {
throw new ElasticsearchStatusException("max running job capacity [" + maxAllowedRunningJobs + "] reached", throw new ElasticsearchStatusException("max running job capacity [" + maxAllowedRunningJobs + "] reached",
@ -245,7 +245,7 @@ public class AutodetectProcessManager extends AbstractComponent {
AutodetectProcess process = null; AutodetectProcess process = null;
try { try {
process = autodetectProcessFactory.createAutodetectProcess(job, modelSnapshot, quantiles, lists, process = autodetectProcessFactory.createAutodetectProcess(job, modelSnapshot, quantiles, filters,
ignoreDowntime, executorService); ignoreDowntime, executorService);
return new AutodetectCommunicator(executorService, job, process, dataCountsReporter, processor, stateProcessor, handler); return new AutodetectCommunicator(executorService, job, process, dataCountsReporter, processor, stateProcessor, handler);
} catch (Exception e) { } catch (Exception e) {

View File

@ -18,7 +18,7 @@ import org.elasticsearch.xpack.ml.job.process.NativeController;
import org.elasticsearch.xpack.ml.job.process.ProcessCtrl; import org.elasticsearch.xpack.ml.job.process.ProcessCtrl;
import org.elasticsearch.xpack.ml.job.process.ProcessPipes; import org.elasticsearch.xpack.ml.job.process.ProcessPipes;
import org.elasticsearch.xpack.ml.job.process.autodetect.state.Quantiles; import org.elasticsearch.xpack.ml.job.process.autodetect.state.Quantiles;
import org.elasticsearch.xpack.ml.job.config.ListDocument; import org.elasticsearch.xpack.ml.job.config.MlFilter;
import org.elasticsearch.xpack.ml.utils.ExceptionsHelper; import org.elasticsearch.xpack.ml.utils.ExceptionsHelper;
import org.elasticsearch.xpack.ml.utils.NamedPipeHelper; import org.elasticsearch.xpack.ml.utils.NamedPipeHelper;
@ -52,12 +52,12 @@ public class NativeAutodetectProcessFactory implements AutodetectProcessFactory
} }
@Override @Override
public AutodetectProcess createAutodetectProcess(Job job, ModelSnapshot modelSnapshot, Quantiles quantiles, Set<ListDocument> list, public AutodetectProcess createAutodetectProcess(Job job, ModelSnapshot modelSnapshot, Quantiles quantiles, Set<MlFilter> filters,
boolean ignoreDowntime, ExecutorService executorService) { boolean ignoreDowntime, ExecutorService executorService) {
List<Path> filesToDelete = new ArrayList<>(); List<Path> filesToDelete = new ArrayList<>();
ProcessPipes processPipes = new ProcessPipes(env, NAMED_PIPE_HELPER, ProcessCtrl.AUTODETECT, job.getId(), ProcessPipes processPipes = new ProcessPipes(env, NAMED_PIPE_HELPER, ProcessCtrl.AUTODETECT, job.getId(),
true, false, true, true, modelSnapshot != null, !ProcessCtrl.DONT_PERSIST_MODEL_STATE_SETTING.get(settings)); true, false, true, true, modelSnapshot != null, !ProcessCtrl.DONT_PERSIST_MODEL_STATE_SETTING.get(settings));
createNativeProcess(job, quantiles, list, processPipes, ignoreDowntime, filesToDelete); createNativeProcess(job, quantiles, filters, processPipes, ignoreDowntime, filesToDelete);
int numberOfAnalysisFields = job.getAnalysisConfig().analysisFields().size(); int numberOfAnalysisFields = job.getAnalysisConfig().analysisFields().size();
NativeAutodetectProcess autodetect = null; NativeAutodetectProcess autodetect = null;
@ -87,13 +87,13 @@ public class NativeAutodetectProcessFactory implements AutodetectProcessFactory
} }
} }
private void createNativeProcess(Job job, Quantiles quantiles, Set<ListDocument> lists, ProcessPipes processPipes, private void createNativeProcess(Job job, Quantiles quantiles, Set<MlFilter> filters, ProcessPipes processPipes,
boolean ignoreDowntime, List<Path> filesToDelete) { boolean ignoreDowntime, List<Path> filesToDelete) {
try { try {
AutodetectBuilder autodetectBuilder = new AutodetectBuilder(job, filesToDelete, LOGGER, env, AutodetectBuilder autodetectBuilder = new AutodetectBuilder(job, filesToDelete, LOGGER, env,
settings, nativeController, processPipes) settings, nativeController, processPipes)
.ignoreDowntime(ignoreDowntime) .ignoreDowntime(ignoreDowntime)
.referencedLists(lists); .referencedFilters(filters);
// if state is null or empty it will be ignored // if state is null or empty it will be ignored
// else it is used to restore the quantiles // else it is used to restore the quantiles

View File

@ -22,7 +22,7 @@ import org.elasticsearch.xpack.ml.job.config.AnalysisConfig;
import org.elasticsearch.xpack.ml.job.config.Detector; import org.elasticsearch.xpack.ml.job.config.Detector;
import org.elasticsearch.xpack.ml.job.config.DefaultDetectorDescription; import org.elasticsearch.xpack.ml.job.config.DefaultDetectorDescription;
import org.elasticsearch.xpack.ml.job.config.DetectionRule; import org.elasticsearch.xpack.ml.job.config.DetectionRule;
import org.elasticsearch.xpack.ml.job.config.ListDocument; import org.elasticsearch.xpack.ml.job.config.MlFilter;
import org.elasticsearch.xpack.ml.utils.MlStrings; import org.elasticsearch.xpack.ml.utils.MlStrings;
public class FieldConfigWriter { public class FieldConfigWriter {
@ -32,7 +32,7 @@ public class FieldConfigWriter {
private static final String INFLUENCER_PREFIX = "influencer."; private static final String INFLUENCER_PREFIX = "influencer.";
private static final String CATEGORIZATION_FIELD_OPTION = " categorizationfield="; private static final String CATEGORIZATION_FIELD_OPTION = " categorizationfield=";
private static final String CATEGORIZATION_FILTER_PREFIX = "categorizationfilter."; private static final String CATEGORIZATION_FILTER_PREFIX = "categorizationfilter.";
private static final String LIST_PREFIX = "list."; private static final String FILTER_PREFIX = "filter.";
// Note: for the Engine API summarycountfield is currently passed as a // Note: for the Engine API summarycountfield is currently passed as a
// command line option to autodetect rather than in the field config file // command line option to autodetect rather than in the field config file
@ -40,14 +40,14 @@ public class FieldConfigWriter {
private static final char NEW_LINE = '\n'; private static final char NEW_LINE = '\n';
private final AnalysisConfig config; private final AnalysisConfig config;
private final Set<ListDocument> lists; private final Set<MlFilter> filters;
private final OutputStreamWriter writer; private final OutputStreamWriter writer;
private final Logger logger; private final Logger logger;
public FieldConfigWriter(AnalysisConfig config, Set<ListDocument> lists, public FieldConfigWriter(AnalysisConfig config, Set<MlFilter> filters,
OutputStreamWriter writer, Logger logger) { OutputStreamWriter writer, Logger logger) {
this.config = Objects.requireNonNull(config); this.config = Objects.requireNonNull(config);
this.lists = Objects.requireNonNull(lists); this.filters = Objects.requireNonNull(filters);
this.writer = Objects.requireNonNull(writer); this.writer = Objects.requireNonNull(writer);
this.logger = Objects.requireNonNull(logger); this.logger = Objects.requireNonNull(logger);
} }
@ -59,7 +59,7 @@ public class FieldConfigWriter {
StringBuilder contents = new StringBuilder(); StringBuilder contents = new StringBuilder();
writeDetectors(contents); writeDetectors(contents);
writeLists(contents); writeFilters(contents);
writeAsEnumeratedSettings(CATEGORIZATION_FILTER_PREFIX, config.getCategorizationFilters(), writeAsEnumeratedSettings(CATEGORIZATION_FILTER_PREFIX, config.getCategorizationFilters(),
contents, true); contents, true);
@ -119,24 +119,24 @@ public class FieldConfigWriter {
contents.append(NEW_LINE); contents.append(NEW_LINE);
} }
private void writeLists(StringBuilder buffer) throws IOException { private void writeFilters(StringBuilder buffer) throws IOException {
for (ListDocument list : lists) { for (MlFilter filter : filters) {
StringBuilder listAsJson = new StringBuilder(); StringBuilder filterAsJson = new StringBuilder();
listAsJson.append('['); filterAsJson.append('[');
boolean first = true; boolean first = true;
for (String item : list.getItems()) { for (String item : filter.getItems()) {
if (first) { if (first) {
first = false; first = false;
} else { } else {
listAsJson.append(','); filterAsJson.append(',');
} }
listAsJson.append('"'); filterAsJson.append('"');
listAsJson.append(item); filterAsJson.append(item);
listAsJson.append('"'); filterAsJson.append('"');
} }
listAsJson.append(']'); filterAsJson.append(']');
buffer.append(LIST_PREFIX).append(list.getId()).append(EQUALS).append(listAsJson) buffer.append(FILTER_PREFIX).append(filter.getId()).append(EQUALS).append(filterAsJson)
.append(NEW_LINE); .append(NEW_LINE);
} }
} }

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License; * or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
package org.elasticsearch.xpack.ml.rest.list; package org.elasticsearch.xpack.ml.rest.filter;
import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
@ -12,23 +12,23 @@ import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.AcknowledgedRestListener; import org.elasticsearch.rest.action.AcknowledgedRestListener;
import org.elasticsearch.xpack.ml.MlPlugin; import org.elasticsearch.xpack.ml.MlPlugin;
import org.elasticsearch.xpack.ml.action.DeleteListAction; import org.elasticsearch.xpack.ml.action.DeleteFilterAction;
import org.elasticsearch.xpack.ml.action.DeleteListAction.Request; import org.elasticsearch.xpack.ml.action.DeleteFilterAction.Request;
import java.io.IOException; import java.io.IOException;
public class RestDeleteListAction extends BaseRestHandler { public class RestDeleteFilterAction extends BaseRestHandler {
public RestDeleteListAction(Settings settings, RestController controller) { public RestDeleteFilterAction(Settings settings, RestController controller) {
super(settings); super(settings);
controller.registerHandler(RestRequest.Method.DELETE, controller.registerHandler(RestRequest.Method.DELETE,
MlPlugin.BASE_PATH + "lists/{" + Request.LIST_ID.getPreferredName() + "}", this); MlPlugin.BASE_PATH + "filters/{" + Request.FILTER_ID.getPreferredName() + "}", this);
} }
@Override @Override
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException { protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
Request request = new Request(restRequest.param(Request.LIST_ID.getPreferredName())); Request request = new Request(restRequest.param(Request.FILTER_ID.getPreferredName()));
return channel -> client.execute(DeleteListAction.INSTANCE, request, new AcknowledgedRestListener<>(channel)); return channel -> client.execute(DeleteFilterAction.INSTANCE, request, new AcknowledgedRestListener<>(channel));
} }
} }

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License; * or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
package org.elasticsearch.xpack.ml.rest.list; package org.elasticsearch.xpack.ml.rest.filter;
import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings; import org.elasticsearch.common.Strings;
@ -13,35 +13,35 @@ import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.RestStatusToXContentListener; import org.elasticsearch.rest.action.RestStatusToXContentListener;
import org.elasticsearch.xpack.ml.MlPlugin; import org.elasticsearch.xpack.ml.MlPlugin;
import org.elasticsearch.xpack.ml.action.GetListAction; import org.elasticsearch.xpack.ml.action.GetFiltersAction;
import org.elasticsearch.xpack.ml.action.util.PageParams; import org.elasticsearch.xpack.ml.action.util.PageParams;
import org.elasticsearch.xpack.ml.job.config.ListDocument; import org.elasticsearch.xpack.ml.job.config.MlFilter;
import java.io.IOException; import java.io.IOException;
public class RestGetListAction extends BaseRestHandler { public class RestGetFiltersAction extends BaseRestHandler {
public RestGetListAction(Settings settings, RestController controller) { public RestGetFiltersAction(Settings settings, RestController controller) {
super(settings); super(settings);
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH + "lists/{" + ListDocument.ID.getPreferredName() + "}", controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH + "filters/{" + MlFilter.ID.getPreferredName() + "}",
this); this);
controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH + "lists/", this); controller.registerHandler(RestRequest.Method.GET, MlPlugin.BASE_PATH + "filters/", this);
} }
@Override @Override
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException { protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
GetListAction.Request getListRequest = new GetListAction.Request(); GetFiltersAction.Request getListRequest = new GetFiltersAction.Request();
String listId = restRequest.param(ListDocument.ID.getPreferredName()); String filterId = restRequest.param(MlFilter.ID.getPreferredName());
if (!Strings.isNullOrEmpty(listId)) { if (!Strings.isNullOrEmpty(filterId)) {
getListRequest.setListId(listId); getListRequest.setFilterId(filterId);
} }
if (restRequest.hasParam(PageParams.FROM.getPreferredName()) if (restRequest.hasParam(PageParams.FROM.getPreferredName())
|| restRequest.hasParam(PageParams.SIZE.getPreferredName()) || restRequest.hasParam(PageParams.SIZE.getPreferredName())
|| Strings.isNullOrEmpty(listId)) { || Strings.isNullOrEmpty(filterId)) {
getListRequest.setPageParams(new PageParams(restRequest.paramAsInt(PageParams.FROM.getPreferredName(), PageParams.DEFAULT_FROM), getListRequest.setPageParams(new PageParams(restRequest.paramAsInt(PageParams.FROM.getPreferredName(), PageParams.DEFAULT_FROM),
restRequest.paramAsInt(PageParams.SIZE.getPreferredName(), PageParams.DEFAULT_SIZE))); restRequest.paramAsInt(PageParams.SIZE.getPreferredName(), PageParams.DEFAULT_SIZE)));
} }
return channel -> client.execute(GetListAction.INSTANCE, getListRequest, new RestStatusToXContentListener<>(channel)); return channel -> client.execute(GetFiltersAction.INSTANCE, getListRequest, new RestStatusToXContentListener<>(channel));
} }
} }

View File

@ -3,7 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License; * or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License. * you may not use this file except in compliance with the Elastic License.
*/ */
package org.elasticsearch.xpack.ml.rest.list; package org.elasticsearch.xpack.ml.rest.filter;
import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
@ -13,22 +13,22 @@ import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest; import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.action.AcknowledgedRestListener; import org.elasticsearch.rest.action.AcknowledgedRestListener;
import org.elasticsearch.xpack.ml.MlPlugin; import org.elasticsearch.xpack.ml.MlPlugin;
import org.elasticsearch.xpack.ml.action.PutListAction; import org.elasticsearch.xpack.ml.action.PutFilterAction;
import java.io.IOException; import java.io.IOException;
public class RestPutListAction extends BaseRestHandler { public class RestPutFilterAction extends BaseRestHandler {
public RestPutListAction(Settings settings, RestController controller) { public RestPutFilterAction(Settings settings, RestController controller) {
super(settings); super(settings);
controller.registerHandler(RestRequest.Method.PUT, MlPlugin.BASE_PATH + "lists", this); controller.registerHandler(RestRequest.Method.PUT, MlPlugin.BASE_PATH + "filters", this);
} }
@Override @Override
protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException { protected RestChannelConsumer prepareRequest(RestRequest restRequest, NodeClient client) throws IOException {
XContentParser parser = restRequest.contentOrSourceParamParser(); XContentParser parser = restRequest.contentOrSourceParamParser();
PutListAction.Request putListRequest = PutListAction.Request.parseRequest(parser); PutFilterAction.Request putListRequest = PutFilterAction.Request.parseRequest(parser);
return channel -> client.execute(PutListAction.INSTANCE, putListRequest, new AcknowledgedRestListener<>(channel)); return channel -> client.execute(PutFilterAction.INSTANCE, putListRequest, new AcknowledgedRestListener<>(channel));
} }
} }

View File

@ -164,9 +164,6 @@ json.job.config.parse.error = JSON parse error reading the job configuration
json.detector.config.mapping.error = JSON mapping error reading the detector configuration json.detector.config.mapping.error = JSON mapping error reading the detector configuration
json.detector.config.parse.error = JSON parse error reading the detector configuration json.detector.config.parse.error = JSON parse error reading the detector configuration
json.list.document.mapping.error = JSON mapping error reading the list
json.list.document.parse.error = JSON parse error reading the list
json.transform.config.mapping.error = JSON mapping error reading the transform configuration json.transform.config.mapping.error = JSON mapping error reading the transform configuration
json.transform.config.parse.error = JSON parse error reading the transform configuration json.transform.config.parse.error = JSON parse error reading the transform configuration

View File

@ -6,14 +6,14 @@
package org.elasticsearch.xpack.ml.action; package org.elasticsearch.xpack.ml.action;
import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.ml.action.PutListAction.Request; import org.elasticsearch.xpack.ml.action.PutFilterAction.Request;
import org.elasticsearch.xpack.ml.job.config.ListDocument; import org.elasticsearch.xpack.ml.job.config.MlFilter;
import org.elasticsearch.xpack.ml.support.AbstractStreamableXContentTestCase; import org.elasticsearch.xpack.ml.support.AbstractStreamableXContentTestCase;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class CreateListActionRequestTests extends AbstractStreamableXContentTestCase<PutListAction.Request> { public class CreateFilterActionRequestTests extends AbstractStreamableXContentTestCase<PutFilterAction.Request> {
@Override @Override
protected Request createTestInstance() { protected Request createTestInstance() {
@ -22,18 +22,18 @@ public class CreateListActionRequestTests extends AbstractStreamableXContentTest
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
items.add(randomAsciiOfLengthBetween(1, 20)); items.add(randomAsciiOfLengthBetween(1, 20));
} }
ListDocument listDocument = new ListDocument(randomAsciiOfLengthBetween(1, 20), items); MlFilter filter = new MlFilter(randomAsciiOfLengthBetween(1, 20), items);
return new PutListAction.Request(listDocument); return new PutFilterAction.Request(filter);
} }
@Override @Override
protected Request createBlankInstance() { protected Request createBlankInstance() {
return new PutListAction.Request(); return new PutFilterAction.Request();
} }
@Override @Override
protected Request parseInstance(XContentParser parser) { protected Request parseInstance(XContentParser parser) {
return PutListAction.Request.parseRequest(parser); return PutFilterAction.Request.parseRequest(parser);
} }
} }

View File

@ -5,18 +5,18 @@
*/ */
package org.elasticsearch.xpack.ml.action; package org.elasticsearch.xpack.ml.action;
import org.elasticsearch.xpack.ml.action.GetListAction.Request; import org.elasticsearch.xpack.ml.action.GetFiltersAction.Request;
import org.elasticsearch.xpack.ml.action.util.PageParams; import org.elasticsearch.xpack.ml.action.util.PageParams;
import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase; import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase;
public class GetListActionRequestTests extends AbstractStreamableTestCase<GetListAction.Request> { public class GetFiltersActionRequestTests extends AbstractStreamableTestCase<GetFiltersAction.Request> {
@Override @Override
protected Request createTestInstance() { protected Request createTestInstance() {
Request request = new Request(); Request request = new Request();
if (randomBoolean()) { if (randomBoolean()) {
request.setListId(randomAsciiOfLengthBetween(1, 20)); request.setFilterId(randomAsciiOfLengthBetween(1, 20));
} else { } else {
if (randomBoolean()) { if (randomBoolean()) {
int from = randomInt(PageParams.MAX_FROM_SIZE_SUM); int from = randomInt(PageParams.MAX_FROM_SIZE_SUM);

View File

@ -5,22 +5,22 @@
*/ */
package org.elasticsearch.xpack.ml.action; package org.elasticsearch.xpack.ml.action;
import org.elasticsearch.xpack.ml.action.GetListAction.Response; import org.elasticsearch.xpack.ml.action.GetFiltersAction.Response;
import org.elasticsearch.xpack.ml.action.util.QueryPage; import org.elasticsearch.xpack.ml.action.util.QueryPage;
import org.elasticsearch.xpack.ml.job.config.ListDocument; import org.elasticsearch.xpack.ml.job.config.MlFilter;
import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase; import org.elasticsearch.xpack.ml.support.AbstractStreamableTestCase;
import java.util.Collections; import java.util.Collections;
public class GetListActionResponseTests extends AbstractStreamableTestCase<GetListAction.Response> { public class GetFiltersActionResponseTests extends AbstractStreamableTestCase<GetFiltersAction.Response> {
@Override @Override
protected Response createTestInstance() { protected Response createTestInstance() {
final QueryPage<ListDocument> result; final QueryPage<MlFilter> result;
ListDocument doc = new ListDocument( MlFilter doc = new MlFilter(
randomAsciiOfLengthBetween(1, 20), Collections.singletonList(randomAsciiOfLengthBetween(1, 20))); randomAsciiOfLengthBetween(1, 20), Collections.singletonList(randomAsciiOfLengthBetween(1, 20)));
result = new QueryPage<>(Collections.singletonList(doc), 1, ListDocument.RESULTS_FIELD); result = new QueryPage<>(Collections.singletonList(doc), 1, MlFilter.RESULTS_FIELD);
return new Response(result); return new Response(result);
} }

View File

@ -398,8 +398,10 @@ public class AnalysisConfigTests extends AbstractSerializingTestCase<AnalysisCon
} }
public void testExtractReferencedLists() { public void testExtractReferencedLists() {
DetectionRule rule1 = new DetectionRule(null, null, Connective.OR, Arrays.asList(RuleCondition.createCategorical("foo", "list1"))); DetectionRule rule1 =
DetectionRule rule2 = new DetectionRule(null, null, Connective.OR, Arrays.asList(RuleCondition.createCategorical("foo", "list2"))); new DetectionRule(null, null, Connective.OR, Arrays.asList(RuleCondition.createCategorical("foo", "filter1")));
DetectionRule rule2 =
new DetectionRule(null, null, Connective.OR, Arrays.asList(RuleCondition.createCategorical("foo", "filter2")));
Detector.Builder detector1 = new Detector.Builder("count", null); Detector.Builder detector1 = new Detector.Builder("count", null);
detector1.setByFieldName("foo"); detector1.setByFieldName("foo");
detector1.setDetectorRules(Arrays.asList(rule1)); detector1.setDetectorRules(Arrays.asList(rule1));
@ -409,7 +411,7 @@ public class AnalysisConfigTests extends AbstractSerializingTestCase<AnalysisCon
AnalysisConfig config = new AnalysisConfig.Builder( AnalysisConfig config = new AnalysisConfig.Builder(
Arrays.asList(detector1.build(), detector2.build(), new Detector.Builder("count", null).build())).build(); Arrays.asList(detector1.build(), detector2.build(), new Detector.Builder("count", null).build())).build();
assertEquals(new HashSet<>(Arrays.asList("list1", "list2")), config.extractReferencedLists()); assertEquals(new HashSet<>(Arrays.asList("filter1", "filter2")), config.extractReferencedFilters());
} }
private static AnalysisConfig createFullyPopulatedConfig() { private static AnalysisConfig createFullyPopulatedConfig() {

View File

@ -22,11 +22,11 @@ public class DetectionRuleTests extends AbstractSerializingTestCase<DetectionRul
new RuleCondition(RuleConditionType.NUMERICAL_ACTUAL, "field", "value", new Condition(Operator.GT, "5"), null); new RuleCondition(RuleConditionType.NUMERICAL_ACTUAL, "field", "value", new Condition(Operator.GT, "5"), null);
List<RuleCondition> conditions = Arrays.asList( List<RuleCondition> conditions = Arrays.asList(
numericalCondition, numericalCondition,
RuleCondition.createCategorical("foo", "list1"), RuleCondition.createCategorical("foo", "filter1"),
RuleCondition.createCategorical("bar", "list2")); RuleCondition.createCategorical("bar", "filter2"));
DetectionRule rule = new DetectionRule(null, null, Connective.OR, conditions); DetectionRule rule = new DetectionRule(null, null, Connective.OR, conditions);
assertEquals(new HashSet<>(Arrays.asList("list1", "list2")), rule.extractReferencedLists()); assertEquals(new HashSet<>(Arrays.asList("filter1", "filter2")), rule.extractReferencedFilters());
} }
public void testEqualsGivenSameObject() { public void testEqualsGivenSameObject() {

View File

@ -111,7 +111,7 @@ public class DetectorTests extends AbstractSerializingTestCase<Detector> {
new DetectionRule(null, null, Connective.OR, Arrays.asList(RuleCondition.createCategorical("by", "list2"))))); new DetectionRule(null, null, Connective.OR, Arrays.asList(RuleCondition.createCategorical("by", "list2")))));
Detector detector = builder.build(); Detector detector = builder.build();
assertEquals(new HashSet<>(Arrays.asList("list1", "list2")), detector.extractReferencedLists()); assertEquals(new HashSet<>(Arrays.asList("list1", "list2")), detector.extractReferencedFilters());
} }
private Detector.Builder createDetector() { private Detector.Builder createDetector() {

View File

@ -13,36 +13,37 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
public class ListDocumentTests extends AbstractSerializingTestCase<ListDocument> { public class MlFilterTests extends AbstractSerializingTestCase<MlFilter> {
@Override @Override
protected ListDocument createTestInstance() { protected MlFilter createTestInstance() {
int size = randomInt(10); int size = randomInt(10);
List<String> items = new ArrayList<>(size); List<String> items = new ArrayList<>(size);
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
items.add(randomAsciiOfLengthBetween(1, 20)); items.add(randomAsciiOfLengthBetween(1, 20));
} }
return new ListDocument(randomAsciiOfLengthBetween(1, 20), items); return new MlFilter(randomAsciiOfLengthBetween(1, 20), items);
} }
@Override @Override
protected Reader<ListDocument> instanceReader() { protected Reader<MlFilter> instanceReader() {
return ListDocument::new; return MlFilter::new;
} }
@Override @Override
protected ListDocument parseInstance(XContentParser parser) { protected MlFilter parseInstance(XContentParser parser) {
return ListDocument.PARSER.apply(parser, null); return MlFilter.PARSER.apply(parser, null);
} }
public void testNullId() { public void testNullId() {
NullPointerException ex = expectThrows(NullPointerException.class, () -> new ListDocument(null, Collections.emptyList())); NullPointerException ex = expectThrows(NullPointerException.class, () -> new MlFilter(null, Collections.emptyList()));
assertEquals(ListDocument.ID.getPreferredName() + " must not be null", ex.getMessage()); assertEquals(MlFilter.ID.getPreferredName() + " must not be null", ex.getMessage());
} }
public void testNullItems() { public void testNullItems() {
NullPointerException ex = expectThrows(NullPointerException.class, () -> new ListDocument(randomAsciiOfLengthBetween(1, 20), null)); NullPointerException ex =
assertEquals(ListDocument.ITEMS.getPreferredName() + " must not be null", ex.getMessage()); expectThrows(NullPointerException.class, () -> new MlFilter(randomAsciiOfLengthBetween(1, 20), null));
assertEquals(MlFilter.ITEMS.getPreferredName() + " must not be null", ex.getMessage());
} }
} }

View File

@ -16,12 +16,12 @@ public class RuleConditionTests extends AbstractSerializingTestCase<RuleConditio
protected RuleCondition createTestInstance() { protected RuleCondition createTestInstance() {
Condition condition = null; Condition condition = null;
String fieldName = null; String fieldName = null;
String valueList = null; String valueFilter = null;
String fieldValue = null; String fieldValue = null;
RuleConditionType r = randomFrom(RuleConditionType.values()); RuleConditionType r = randomFrom(RuleConditionType.values());
switch (r) { switch (r) {
case CATEGORICAL: case CATEGORICAL:
valueList = randomAsciiOfLengthBetween(1, 20); valueFilter = randomAsciiOfLengthBetween(1, 20);
if (randomBoolean()) { if (randomBoolean()) {
fieldName = randomAsciiOfLengthBetween(1, 20); fieldName = randomAsciiOfLengthBetween(1, 20);
} }
@ -36,7 +36,7 @@ public class RuleConditionTests extends AbstractSerializingTestCase<RuleConditio
} }
break; break;
} }
return new RuleCondition(r, fieldName, fieldValue, condition, valueList); return new RuleCondition(r, fieldName, fieldValue, condition, valueFilter);
} }
@Override @Override
@ -50,7 +50,7 @@ public class RuleConditionTests extends AbstractSerializingTestCase<RuleConditio
} }
public void testConstructor() { public void testConstructor() {
RuleCondition condition = new RuleCondition(RuleConditionType.CATEGORICAL, null, null, null, "valueList"); RuleCondition condition = new RuleCondition(RuleConditionType.CATEGORICAL, null, null, null, "valueFilter");
assertEquals(RuleConditionType.CATEGORICAL, condition.getConditionType()); assertEquals(RuleConditionType.CATEGORICAL, condition.getConditionType());
assertNull(condition.getFieldName()); assertNull(condition.getFieldName());
assertNull(condition.getFieldValue()); assertNull(condition.getFieldValue());
@ -58,17 +58,17 @@ public class RuleConditionTests extends AbstractSerializingTestCase<RuleConditio
} }
public void testEqualsGivenSameObject() { public void testEqualsGivenSameObject() {
RuleCondition condition = new RuleCondition(RuleConditionType.CATEGORICAL, null, null, null, "valueList"); RuleCondition condition = new RuleCondition(RuleConditionType.CATEGORICAL, null, null, null, "valueFilter");
assertTrue(condition.equals(condition)); assertTrue(condition.equals(condition));
} }
public void testEqualsGivenString() { public void testEqualsGivenString() {
assertFalse(new RuleCondition(RuleConditionType.CATEGORICAL, null, null, null, "list").equals("a string")); assertFalse(new RuleCondition(RuleConditionType.CATEGORICAL, null, null, null, "filter").equals("a string"));
} }
public void testEqualsGivenDifferentType() { public void testEqualsGivenDifferentType() {
RuleCondition condition1 = createFullyPopulated(); RuleCondition condition1 = createFullyPopulated();
RuleCondition condition2 = new RuleCondition(RuleConditionType.CATEGORICAL, null, null, null, "valueList"); RuleCondition condition2 = new RuleCondition(RuleConditionType.CATEGORICAL, null, null, null, "valueFilter");
assertFalse(condition1.equals(condition2)); assertFalse(condition1.equals(condition2));
assertFalse(condition2.equals(condition1)); assertFalse(condition2.equals(condition1));
} }
@ -97,9 +97,9 @@ public class RuleConditionTests extends AbstractSerializingTestCase<RuleConditio
assertFalse(condition2.equals(condition1)); assertFalse(condition2.equals(condition1));
} }
public void testEqualsGivenDifferentValueList() { public void testEqualsGivenDifferentValueFilter() {
RuleCondition condition1 = new RuleCondition(RuleConditionType.CATEGORICAL, null, null, null, "myList"); RuleCondition condition1 = new RuleCondition(RuleConditionType.CATEGORICAL, null, null, null, "myFilter");
RuleCondition condition2 = new RuleCondition(RuleConditionType.CATEGORICAL, null, null, null, "myListaaa"); RuleCondition condition2 = new RuleCondition(RuleConditionType.CATEGORICAL, null, null, null, "myFilteraaa");
assertFalse(condition1.equals(condition2)); assertFalse(condition1.equals(condition2));
assertFalse(condition2.equals(condition1)); assertFalse(condition2.equals(condition1));
} }
@ -121,16 +121,16 @@ public class RuleConditionTests extends AbstractSerializingTestCase<RuleConditio
assertEquals("Invalid detector rule: a categorical rule_condition does not support field_value", e.getMessage()); assertEquals("Invalid detector rule: a categorical rule_condition does not support field_value", e.getMessage());
} }
public void testVerify_GivenCategoricalWithoutValueList() { public void testVerify_GivenCategoricalWithoutValueFilter() {
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> new RuleCondition(RuleConditionType.CATEGORICAL, null, null, null, null)); () -> new RuleCondition(RuleConditionType.CATEGORICAL, null, null, null, null));
assertEquals("Invalid detector rule: a categorical rule_condition requires value_list to be set", e.getMessage()); assertEquals("Invalid detector rule: a categorical rule_condition requires value_filter to be set", e.getMessage());
} }
public void testVerify_GivenNumericalActualWithValueList() { public void testVerify_GivenNumericalActualWithValueFilter() {
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> new RuleCondition(RuleConditionType.NUMERICAL_ACTUAL, null, null, null, "myList")); () -> new RuleCondition(RuleConditionType.NUMERICAL_ACTUAL, null, null, null, "myFilter"));
assertEquals("Invalid detector rule: a numerical rule_condition does not support value_list", e.getMessage()); assertEquals("Invalid detector rule: a numerical rule_condition does not support value_filter", e.getMessage());
} }
public void testVerify_GivenNumericalActualWithoutCondition() { public void testVerify_GivenNumericalActualWithoutCondition() {
@ -145,10 +145,10 @@ public class RuleConditionTests extends AbstractSerializingTestCase<RuleConditio
assertEquals("Invalid detector rule: a numerical rule_condition with field_name requires that field_value is set", e.getMessage()); assertEquals("Invalid detector rule: a numerical rule_condition with field_name requires that field_value is set", e.getMessage());
} }
public void testVerify_GivenNumericalTypicalWithValueList() { public void testVerify_GivenNumericalTypicalWithValueFilter() {
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> new RuleCondition(RuleConditionType.NUMERICAL_ACTUAL, null, null, null, "myList")); () -> new RuleCondition(RuleConditionType.NUMERICAL_ACTUAL, null, null, null, "myFilter"));
assertEquals("Invalid detector rule: a numerical rule_condition does not support value_list", e.getMessage()); assertEquals("Invalid detector rule: a numerical rule_condition does not support value_filter", e.getMessage());
} }
public void testVerify_GivenNumericalTypicalWithoutCondition() { public void testVerify_GivenNumericalTypicalWithoutCondition() {
@ -157,10 +157,10 @@ public class RuleConditionTests extends AbstractSerializingTestCase<RuleConditio
assertEquals("Invalid detector rule: a numerical rule_condition requires condition to be set", e.getMessage()); assertEquals("Invalid detector rule: a numerical rule_condition requires condition to be set", e.getMessage());
} }
public void testVerify_GivenNumericalDiffAbsWithValueList() { public void testVerify_GivenNumericalDiffAbsWithValueFilter() {
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, IllegalArgumentException e = expectThrows(IllegalArgumentException.class,
() -> new RuleCondition(RuleConditionType.NUMERICAL_DIFF_ABS, null, null, null, "myList")); () -> new RuleCondition(RuleConditionType.NUMERICAL_DIFF_ABS, null, null, null, "myFilter"));
assertEquals("Invalid detector rule: a numerical rule_condition does not support value_list", e.getMessage()); assertEquals("Invalid detector rule: a numerical rule_condition does not support value_filter", e.getMessage());
} }
public void testVerify_GivenNumericalDiffAbsWithoutCondition() { public void testVerify_GivenNumericalDiffAbsWithoutCondition() {
@ -199,7 +199,7 @@ public class RuleConditionTests extends AbstractSerializingTestCase<RuleConditio
public void testVerify_GivenValidCategorical() { public void testVerify_GivenValidCategorical() {
// no validation error: // no validation error:
new RuleCondition(RuleConditionType.CATEGORICAL, "metric", null, null, "myList"); new RuleCondition(RuleConditionType.CATEGORICAL, "metric", null, null, "myFilter");
} }
public void testVerify_GivenValidNumericalActual() { public void testVerify_GivenValidNumericalActual() {

View File

@ -21,7 +21,7 @@ import org.elasticsearch.xpack.ml.job.results.CategoryDefinition;
import org.elasticsearch.xpack.ml.job.results.ReservedFieldNames; import org.elasticsearch.xpack.ml.job.results.ReservedFieldNames;
import org.elasticsearch.xpack.ml.job.results.Result; import org.elasticsearch.xpack.ml.job.results.Result;
import org.elasticsearch.xpack.ml.job.usage.Usage; import org.elasticsearch.xpack.ml.job.usage.Usage;
import org.elasticsearch.xpack.ml.job.config.ListDocument; import org.elasticsearch.xpack.ml.job.config.MlFilter;
import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParseException;
@ -84,7 +84,7 @@ public class ElasticsearchMappingsTests extends ESTestCase {
overridden.add(CategorizerState.TYPE); overridden.add(CategorizerState.TYPE);
overridden.add(CategoryDefinition.TYPE.getPreferredName()); overridden.add(CategoryDefinition.TYPE.getPreferredName());
overridden.add(Job.TYPE); overridden.add(Job.TYPE);
overridden.add(ListDocument.TYPE.getPreferredName()); overridden.add(MlFilter.TYPE.getPreferredName());
overridden.add(ModelState.TYPE.getPreferredName()); overridden.add(ModelState.TYPE.getPreferredName());
overridden.add(ModelSizeStats.RESULT_TYPE_FIELD.getPreferredName()); overridden.add(ModelSizeStats.RESULT_TYPE_FIELD.getPreferredName());
overridden.add(ModelSnapshot.TYPE.getPreferredName()); overridden.add(ModelSnapshot.TYPE.getPreferredName());
@ -93,8 +93,8 @@ public class ElasticsearchMappingsTests extends ESTestCase {
// These are not reserved because they're in the ml-int index // These are not reserved because they're in the ml-int index
// not the job indices // not the job indices
overridden.add(ListDocument.ID.getPreferredName()); overridden.add(MlFilter.ID.getPreferredName());
overridden.add(ListDocument.ITEMS.getPreferredName()); overridden.add(MlFilter.ITEMS.getPreferredName());
// These are not reserved because they're analyzed strings, i.e. the // These are not reserved because they're analyzed strings, i.e. the
// same type as user-specified fields // same type as user-specified fields

View File

@ -20,7 +20,7 @@ import org.elasticsearch.xpack.ml.job.config.DataDescription;
import org.elasticsearch.xpack.ml.job.config.Detector; import org.elasticsearch.xpack.ml.job.config.Detector;
import org.elasticsearch.xpack.ml.job.config.Job; import org.elasticsearch.xpack.ml.job.config.Job;
import org.elasticsearch.xpack.ml.job.config.JobStatus; import org.elasticsearch.xpack.ml.job.config.JobStatus;
import org.elasticsearch.xpack.ml.job.config.ListDocument; import org.elasticsearch.xpack.ml.job.config.MlFilter;
import org.elasticsearch.xpack.ml.job.metadata.Allocation; import org.elasticsearch.xpack.ml.job.metadata.Allocation;
import org.elasticsearch.xpack.ml.job.persistence.JobDataCountsPersister; import org.elasticsearch.xpack.ml.job.persistence.JobDataCountsPersister;
import org.elasticsearch.xpack.ml.job.persistence.JobProvider; import org.elasticsearch.xpack.ml.job.persistence.JobProvider;
@ -139,7 +139,7 @@ public class AutodetectProcessManagerTests extends ESTestCase {
AutodetectProcess autodetectProcess = mock(AutodetectProcess.class); AutodetectProcess autodetectProcess = mock(AutodetectProcess.class);
when(autodetectProcess.isProcessAlive()).thenReturn(true); when(autodetectProcess.isProcessAlive()).thenReturn(true);
when(autodetectProcess.getPersistStream()).thenReturn(new ByteArrayInputStream(new byte[0])); when(autodetectProcess.getPersistStream()).thenReturn(new ByteArrayInputStream(new byte[0]));
AutodetectProcessFactory autodetectProcessFactory = (j, modelSnapshot, quantiles, lists, i, e) -> autodetectProcess; AutodetectProcessFactory autodetectProcessFactory = (j, modelSnapshot, quantiles, filters, i, e) -> autodetectProcess;
Settings.Builder settings = Settings.builder(); Settings.Builder settings = Settings.builder();
settings.put(AutodetectProcessManager.MAX_RUNNING_JOBS_PER_NODE.getKey(), 3); settings.put(AutodetectProcessManager.MAX_RUNNING_JOBS_PER_NODE.getKey(), 3);
AutodetectProcessManager manager = spy(new AutodetectProcessManager(settings.build(), client, threadPool, jobManager, jobProvider, AutodetectProcessManager manager = spy(new AutodetectProcessManager(settings.build(), client, threadPool, jobManager, jobProvider,
@ -148,10 +148,10 @@ public class AutodetectProcessManagerTests extends ESTestCase {
ModelSnapshot modelSnapshot = new ModelSnapshot("foo"); ModelSnapshot modelSnapshot = new ModelSnapshot("foo");
Quantiles quantiles = new Quantiles("foo", new Date(), "state"); Quantiles quantiles = new Quantiles("foo", new Date(), "state");
Set<ListDocument> lists = new HashSet<>(); Set<MlFilter> filters = new HashSet<>();
doAnswer(invocationOnMock -> { doAnswer(invocationOnMock -> {
AutodetectProcessManager.TriConsumer consumer = (AutodetectProcessManager.TriConsumer) invocationOnMock.getArguments()[1]; AutodetectProcessManager.TriConsumer consumer = (AutodetectProcessManager.TriConsumer) invocationOnMock.getArguments()[1];
consumer.accept(modelSnapshot, quantiles, lists); consumer.accept(modelSnapshot, quantiles, filters);
return null; return null;
}).when(manager).gatherRequiredInformation(any(), any(), any()); }).when(manager).gatherRequiredInformation(any(), any(), any());
@ -298,20 +298,20 @@ public class AutodetectProcessManagerTests extends ESTestCase {
AutodetectResultsParser parser = mock(AutodetectResultsParser.class); AutodetectResultsParser parser = mock(AutodetectResultsParser.class);
AutodetectProcess autodetectProcess = mock(AutodetectProcess.class); AutodetectProcess autodetectProcess = mock(AutodetectProcess.class);
AutodetectProcessFactory autodetectProcessFactory = (j, modelSnapshot, quantiles, lists, i, e) -> autodetectProcess; AutodetectProcessFactory autodetectProcessFactory = (j, modelSnapshot, quantiles, filters, i, e) -> autodetectProcess;
AutodetectProcessManager manager = spy(new AutodetectProcessManager(Settings.EMPTY, client, threadPool, jobManager, jobProvider, AutodetectProcessManager manager = spy(new AutodetectProcessManager(Settings.EMPTY, client, threadPool, jobManager, jobProvider,
jobResultsPersister, jobRenormalizedResultsPersister, jobDataCountsPersister, parser, autodetectProcessFactory, jobResultsPersister, jobRenormalizedResultsPersister, jobDataCountsPersister, parser, autodetectProcessFactory,
normalizerFactory)); normalizerFactory));
ModelSnapshot modelSnapshot = new ModelSnapshot("foo"); ModelSnapshot modelSnapshot = new ModelSnapshot("foo");
Quantiles quantiles = new Quantiles("foo", new Date(), "state"); Quantiles quantiles = new Quantiles("foo", new Date(), "state");
Set<ListDocument> lists = new HashSet<>(); Set<MlFilter> filters = new HashSet<>();
doAnswer(invocationOnMock -> { doAnswer(invocationOnMock -> {
AutodetectProcessManager.TriConsumer consumer = (AutodetectProcessManager.TriConsumer) invocationOnMock.getArguments()[1]; AutodetectProcessManager.TriConsumer consumer = (AutodetectProcessManager.TriConsumer) invocationOnMock.getArguments()[1];
consumer.accept(modelSnapshot, quantiles, lists); consumer.accept(modelSnapshot, quantiles, filters);
return null; return null;
}).when(manager).gatherRequiredInformation(any(), any(), any()); }).when(manager).gatherRequiredInformation(any(), any(), any());
expectThrows(EsRejectedExecutionException.class, () -> manager.create("my_id", modelSnapshot, quantiles, lists, false, e -> {})); expectThrows(EsRejectedExecutionException.class, () -> manager.create("my_id", modelSnapshot, quantiles, filters, false, e -> {}));
verify(autodetectProcess, times(1)).close(); verify(autodetectProcess, times(1)).close();
} }
@ -336,13 +336,13 @@ public class AutodetectProcessManagerTests extends ESTestCase {
manager = spy(manager); manager = spy(manager);
ModelSnapshot modelSnapshot = new ModelSnapshot("foo"); ModelSnapshot modelSnapshot = new ModelSnapshot("foo");
Quantiles quantiles = new Quantiles("foo", new Date(), "state"); Quantiles quantiles = new Quantiles("foo", new Date(), "state");
Set<ListDocument> lists = new HashSet<>(); Set<MlFilter> filters = new HashSet<>();
doAnswer(invocationOnMock -> { doAnswer(invocationOnMock -> {
AutodetectProcessManager.TriConsumer consumer = (AutodetectProcessManager.TriConsumer) invocationOnMock.getArguments()[1]; AutodetectProcessManager.TriConsumer consumer = (AutodetectProcessManager.TriConsumer) invocationOnMock.getArguments()[1];
consumer.accept(modelSnapshot, quantiles, lists); consumer.accept(modelSnapshot, quantiles, filters);
return null; return null;
}).when(manager).gatherRequiredInformation(any(), any(), any()); }).when(manager).gatherRequiredInformation(any(), any(), any());
doReturn(communicator).when(manager).create(any(), eq(modelSnapshot), eq(quantiles), eq(lists), anyBoolean(), any()); doReturn(communicator).when(manager).create(any(), eq(modelSnapshot), eq(quantiles), eq(filters), anyBoolean(), any());
return manager; return manager;
} }

View File

@ -39,18 +39,18 @@ import org.elasticsearch.xpack.ml.job.config.Operator;
import org.elasticsearch.xpack.ml.job.config.DetectionRule; import org.elasticsearch.xpack.ml.job.config.DetectionRule;
import org.elasticsearch.xpack.ml.job.config.RuleCondition; import org.elasticsearch.xpack.ml.job.config.RuleCondition;
import org.elasticsearch.xpack.ml.job.config.RuleConditionType; import org.elasticsearch.xpack.ml.job.config.RuleConditionType;
import org.elasticsearch.xpack.ml.job.config.ListDocument; import org.elasticsearch.xpack.ml.job.config.MlFilter;
public class FieldConfigWriterTests extends ESTestCase { public class FieldConfigWriterTests extends ESTestCase {
private AnalysisConfig analysisConfig; private AnalysisConfig analysisConfig;
private Set<ListDocument> lists; private Set<MlFilter> filters;
private OutputStreamWriter writer; private OutputStreamWriter writer;
@Before @Before
public void setUpDeps() { public void setUpDeps() {
analysisConfig = new AnalysisConfig.Builder(Collections.singletonList(new Detector.Builder("count", null).build())).build(); analysisConfig = new AnalysisConfig.Builder(Collections.singletonList(new Detector.Builder("count", null).build())).build();
lists = new LinkedHashSet<>(); filters = new LinkedHashSet<>();
} }
public void testMultipleDetectorsToConfFile() public void testMultipleDetectorsToConfFile()
@ -202,25 +202,25 @@ public class FieldConfigWriterTests extends ESTestCase {
assertEquals("[" + rule.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS).string() + "]\n", rulesJson); assertEquals("[" + rule.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS).string() + "]\n", rulesJson);
} }
public void testWrite_GivenLists() throws IOException { public void testWrite_GivenFilters() throws IOException {
Detector d = new Detector.Builder("count", null).build(); Detector d = new Detector.Builder("count", null).build();
AnalysisConfig.Builder builder = new AnalysisConfig.Builder(Arrays.asList(d)); AnalysisConfig.Builder builder = new AnalysisConfig.Builder(Arrays.asList(d));
analysisConfig = builder.build(); analysisConfig = builder.build();
lists.add(new ListDocument("list_1", Arrays.asList("a", "b"))); filters.add(new MlFilter("filter_1", Arrays.asList("a", "b")));
lists.add(new ListDocument("list_2", Arrays.asList("c", "d"))); filters.add(new MlFilter("filter_2", Arrays.asList("c", "d")));
writer = mock(OutputStreamWriter.class); writer = mock(OutputStreamWriter.class);
createFieldConfigWriter().write(); createFieldConfigWriter().write();
verify(writer).write("detector.0.clause = count\n" + verify(writer).write("detector.0.clause = count\n" +
"list.list_1 = [\"a\",\"b\"]\n" + "filter.filter_1 = [\"a\",\"b\"]\n" +
"list.list_2 = [\"c\",\"d\"]\n"); "filter.filter_2 = [\"c\",\"d\"]\n");
verifyNoMoreInteractions(writer); verifyNoMoreInteractions(writer);
} }
private FieldConfigWriter createFieldConfigWriter() { private FieldConfigWriter createFieldConfigWriter() {
return new FieldConfigWriter(analysisConfig, lists, writer, mock(Logger.class)); return new FieldConfigWriter(analysisConfig, filters, writer, mock(Logger.class));
} }
} }

View File

@ -0,0 +1,17 @@
{
"xpack.ml.delete_filter": {
"methods": [ "DELETE" ],
"url": {
"path": "/_xpack/ml/filters/{filter_id}",
"paths": [ "/_xpack/ml/filters/{filter_id}" ],
"parts": {
"filter_id": {
"type" : "string",
"required" : true,
"description" : "The ID of the filter to delete"
}
}
},
"body": null
}
}

View File

@ -1,17 +0,0 @@
{
"xpack.ml.delete_list": {
"methods": [ "DELETE" ],
"url": {
"path": "/_xpack/ml/lists/{list_id}",
"paths": [ "/_xpack/ml/lists/{list_id}" ],
"parts": {
"list_id": {
"type" : "string",
"required" : true,
"description" : "The ID of the list to delete"
}
}
},
"body": null
}
}

View File

@ -0,0 +1,26 @@
{
"xpack.ml.get_filters": {
"methods": [ "GET" ],
"url": {
"path": "/_xpack/ml/filters/{filter_id}",
"paths": [ "/_xpack/ml/filters/", "/_xpack/ml/filters/{filter_id}" ],
"parts": {
"filter_id": {
"type" : "string",
"description" : "The ID of the filter to fetch"
}
},
"params": {
"from": {
"type": "int",
"description": "skips a number of filters"
},
"size": {
"type": "int",
"description": "specifies a max number of filters to get"
}
}
},
"body": null
}
}

View File

@ -1,26 +0,0 @@
{
"xpack.ml.get_lists": {
"methods": [ "GET" ],
"url": {
"path": "/_xpack/ml/lists/{list_id}",
"paths": [ "/_xpack/ml/lists/", "/_xpack/ml/lists/{list_id}" ],
"parts": {
"list_id": {
"type" : "string",
"description" : "The ID of the list to fetch"
}
},
"params": {
"from": {
"type": "int",
"description": "skips a number of lists"
},
"size": {
"type": "int",
"description": "specifies a max number of lists to get"
}
}
},
"body": null
}
}

View File

@ -0,0 +1,14 @@
{
"xpack.ml.put_filter": {
"methods": [ "PUT" ],
"url": {
"path": "/_xpack/ml/filters",
"paths": [ "/_xpack/ml/filters" ],
"params": {}
},
"body": {
"description" : "The filter details",
"required" : true
}
}
}

View File

@ -1,14 +0,0 @@
{
"xpack.ml.put_list": {
"methods": [ "PUT" ],
"url": {
"path": "/_xpack/ml/lists",
"paths": [ "/_xpack/ml/lists" ],
"params": {}
},
"body": {
"description" : "The list details",
"required" : true
}
}
}

View File

@ -1,7 +1,7 @@
--- ---
setup: setup:
- do: - do:
xpack.ml.put_list: xpack.ml.put_filter:
body: > body: >
{ {
"id": "foo", "id": "foo",
@ -9,7 +9,7 @@ setup:
} }
- do: - do:
xpack.ml.put_list: xpack.ml.put_filter:
body: > body: >
{ {
"id": "foo2", "id": "foo2",
@ -20,45 +20,45 @@ setup:
indices.refresh: {} indices.refresh: {}
--- ---
"Test get list API with bad ID": "Test get filter API with bad ID":
- do: - do:
catch: missing catch: missing
xpack.ml.get_lists: xpack.ml.get_filters:
list_id: "do_not_exist" filter_id: "do_not_exist"
--- ---
"Test get list API": "Test get filter API":
- do: - do:
xpack.ml.get_lists: xpack.ml.get_filters:
list_id: "foo" filter_id: "foo"
- match: { count: 1 } - match: { count: 1 }
- match: - match:
lists.0: filters.0:
id: "foo" id: "foo"
items: ["abc", "xyz"] items: ["abc", "xyz"]
--- ---
"Test get lists API": "Test get filters API":
- do: - do:
xpack.ml.get_lists: {} xpack.ml.get_filters: {}
- match: { count: 2 } - match: { count: 2 }
- match: - match:
lists.0: filters.0:
id: "foo" id: "foo"
items: ["abc", "xyz"] items: ["abc", "xyz"]
- match: - match:
lists.1: filters.1:
id: "foo2" id: "foo2"
items: ["123", "lmnop"] items: ["123", "lmnop"]
- do: - do:
xpack.ml.get_lists: xpack.ml.get_filters:
from: 1 from: 1
size: 1 size: 1
@ -69,26 +69,26 @@ setup:
- do: - do:
catch: request catch: request
xpack.ml.get_lists: xpack.ml.get_filters:
list_id: "foo" filter_id: "foo"
from: 0 from: 0
- do: - do:
catch: request catch: request
xpack.ml.get_lists: xpack.ml.get_filters:
list_id: "foo" filter_id: "foo"
size: 1 size: 1
- do: - do:
catch: request catch: request
xpack.ml.get_lists: xpack.ml.get_filters:
list_id: "foo" filter_id: "foo"
from: 0 from: 0
size: 1 size: 1
--- ---
"Test create list api": "Test create filter api":
- do: - do:
xpack.ml.put_list: xpack.ml.put_filter:
body: > body: >
{ {
"id": "foo2", "id": "foo2",
@ -98,27 +98,27 @@ setup:
- match: { acknowledged: true } - match: { acknowledged: true }
- do: - do:
xpack.ml.get_lists: xpack.ml.get_filters:
list_id: "foo2" filter_id: "foo2"
- match: { count: 1 } - match: { count: 1 }
- match: - match:
lists.0: filters.0:
id: "foo2" id: "foo2"
items: ["abc", "xyz"] items: ["abc", "xyz"]
--- ---
"Test create list api without ID": "Test create filter api without ID":
- do: - do:
catch: /illegal_argument_exception/ catch: /illegal_argument_exception/
xpack.ml.put_list: xpack.ml.put_filter:
body: > body: >
{ {
"items": ["abc", "xyz"] "items": ["abc", "xyz"]
} }
--- ---
"Test delete in-use list": "Test delete in-use filter":
- do: - do:
xpack.ml.put_job: xpack.ml.put_job:
job_id: farequote2 job_id: farequote2
@ -134,7 +134,7 @@ setup:
"rule_conditions": [ "rule_conditions": [
{ {
"condition_type": "categorical", "condition_type": "categorical",
"value_list": "foo" "value_filter": "foo"
} }
] ]
} }
@ -148,34 +148,34 @@ setup:
} }
- do: - do:
catch: conflict catch: conflict
xpack.ml.delete_list: xpack.ml.delete_filter:
list_id: "foo" filter_id: "foo"
--- ---
"Test non-existing list": "Test non-existing filter":
- do: - do:
catch: missing catch: missing
xpack.ml.delete_list: xpack.ml.delete_filter:
list_id: "does_not_exist" filter_id: "does_not_exist"
--- ---
"Test valid delete list": "Test valid delete filter":
- do: - do:
xpack.ml.get_lists: xpack.ml.get_filters:
list_id: "foo" filter_id: "foo"
- match: { count: 1 } - match: { count: 1 }
- match: - match:
lists.0: filters.0:
id: "foo" id: "foo"
items: ["abc", "xyz"] items: ["abc", "xyz"]
- do: - do:
xpack.ml.delete_list: xpack.ml.delete_filter:
list_id: "foo" filter_id: "foo"
- do: - do:
catch: missing catch: missing
xpack.ml.get_lists: xpack.ml.get_filters:
list_id: "foo" filter_id: "foo"

View File

@ -0,0 +1,19 @@
---
"Test get all filter given no filter exists":
- do:
xpack.ml.put_filter:
body: >
{
"id": "foo",
"items": ["abc", "xyz"]
}
- do:
xpack.ml.delete_filter:
filter_id: "foo"
- do:
xpack.ml.get_filters: {}
- match: { count: 0 }
- match: { filters: [] }

View File

@ -1,19 +0,0 @@
---
"Test get all lists given no list exists":
- do:
xpack.ml.put_list:
body: >
{
"id": "foo",
"items": ["abc", "xyz"]
}
- do:
xpack.ml.delete_list:
list_id: "foo"
- do:
xpack.ml.get_lists: {}
- match: { count: 0 }
- match: { lists: [] }