[ML] Remove partition_field param from GetBucketsAction (elastic/x-pack-elasticsearch#1122)

Relates elastic/x-pack-elasticsearch#1119


Original commit: elastic/x-pack-elasticsearch@c87fdbc031
This commit is contained in:
Dimitris Athanasiou 2017-04-19 14:07:51 +01:00 committed by GitHub
parent 03170d870b
commit 96cfbc8f4c
10 changed files with 4 additions and 80 deletions

View File

@ -45,10 +45,6 @@ privileges to use this API. For more information, see <<privileges-list-cluster>
`include_interim`::
(boolean) If true, the output includes interim results.
`partition_value`::
(string) If `expand` is true, the anomaly records are filtered by this
partition value.
`size`::
(integer) Specifies the maximum number of buckets to obtain.

View File

@ -37,10 +37,6 @@ privileges to use this API. For more information, see <<privileges-list-cluster>
`include_interim`::
(boolean) If true, the output includes interim results.
`partition_value`::
(string) If `expand` is true, the records are filtered by this
partition value.
`record_score`::
(double) Returns records with anomaly scores higher than this value.

View File

@ -65,7 +65,6 @@ public class GetBucketsAction extends Action<GetBucketsAction.Request, GetBucket
public static final ParseField EXPAND = new ParseField("expand");
public static final ParseField INCLUDE_INTERIM = new ParseField("include_interim");
public static final ParseField PARTITION_VALUE = new ParseField("partition_value");
public static final ParseField START = new ParseField("start");
public static final ParseField END = new ParseField("end");
public static final ParseField ANOMALY_SCORE = new ParseField("anomaly_score");
@ -76,16 +75,12 @@ public class GetBucketsAction extends Action<GetBucketsAction.Request, GetBucket
static {
PARSER.declareString((request, jobId) -> request.jobId = jobId, Job.ID);
PARSER.declareString(Request::setTimestamp, Result.TIMESTAMP);
PARSER.declareString(Request::setPartitionValue, PARTITION_VALUE);
PARSER.declareBoolean(Request::setExpand, EXPAND);
PARSER.declareBoolean(Request::setIncludeInterim, INCLUDE_INTERIM);
PARSER.declareStringOrNull(Request::setStart, START);
PARSER.declareStringOrNull(Request::setEnd, END);
PARSER.declareBoolean(Request::setExpand, EXPAND);
PARSER.declareBoolean(Request::setIncludeInterim, INCLUDE_INTERIM);
PARSER.declareObject(Request::setPageParams, PageParams.PARSER, PageParams.PAGE);
PARSER.declareDouble(Request::setAnomalyScore, ANOMALY_SCORE);
PARSER.declareString(Request::setPartitionValue, PARTITION_VALUE);
}
public static Request parseRequest(String jobId, XContentParser parser) {
@ -100,7 +95,6 @@ public class GetBucketsAction extends Action<GetBucketsAction.Request, GetBucket
private String timestamp;
private boolean expand = false;
private boolean includeInterim = false;
private String partitionValue;
private String start;
private String end;
private PageParams pageParams;
@ -149,18 +143,6 @@ public class GetBucketsAction extends Action<GetBucketsAction.Request, GetBucket
this.includeInterim = includeInterim;
}
public String getPartitionValue() {
return partitionValue;
}
public void setPartitionValue(String partitionValue) {
if (timestamp != null) {
throw new IllegalArgumentException("Param [" + PARTITION_VALUE.getPreferredName() + "] is incompatible with ["
+ TIMESTAMP.getPreferredName() + "].");
}
this.partitionValue = partitionValue;
}
public String getStart() {
return start;
}
@ -221,7 +203,6 @@ public class GetBucketsAction extends Action<GetBucketsAction.Request, GetBucket
timestamp = in.readOptionalString();
expand = in.readBoolean();
includeInterim = in.readBoolean();
partitionValue = in.readOptionalString();
start = in.readOptionalString();
end = in.readOptionalString();
anomalyScore = in.readOptionalDouble();
@ -235,7 +216,6 @@ public class GetBucketsAction extends Action<GetBucketsAction.Request, GetBucket
out.writeOptionalString(timestamp);
out.writeBoolean(expand);
out.writeBoolean(includeInterim);
out.writeOptionalString(partitionValue);
out.writeOptionalString(start);
out.writeOptionalString(end);
out.writeOptionalDouble(anomalyScore);
@ -251,9 +231,6 @@ public class GetBucketsAction extends Action<GetBucketsAction.Request, GetBucket
}
builder.field(EXPAND.getPreferredName(), expand);
builder.field(INCLUDE_INTERIM.getPreferredName(), includeInterim);
if (partitionValue != null) {
builder.field(PARTITION_VALUE.getPreferredName(), partitionValue);
}
if (start != null) {
builder.field(START.getPreferredName(), start);
}
@ -272,8 +249,7 @@ public class GetBucketsAction extends Action<GetBucketsAction.Request, GetBucket
@Override
public int hashCode() {
return Objects.hash(jobId, timestamp, partitionValue, expand, includeInterim,
anomalyScore, pageParams, start, end);
return Objects.hash(jobId, timestamp, expand, includeInterim, anomalyScore, pageParams, start, end);
}
@Override
@ -287,7 +263,6 @@ public class GetBucketsAction extends Action<GetBucketsAction.Request, GetBucket
Request other = (Request) obj;
return Objects.equals(jobId, other.jobId) &&
Objects.equals(timestamp, other.timestamp) &&
Objects.equals(partitionValue, other.partitionValue) &&
Objects.equals(expand, other.expand) &&
Objects.equals(includeInterim, other.includeInterim) &&
Objects.equals(anomalyScore, other.anomalyScore) &&
@ -387,8 +362,7 @@ public class GetBucketsAction extends Action<GetBucketsAction.Request, GetBucket
.includeInterim(request.includeInterim)
.start(request.start)
.end(request.end)
.anomalyScoreThreshold(request.anomalyScore)
.partitionValue(request.partitionValue);
.anomalyScoreThreshold(request.anomalyScore);
if (request.pageParams != null) {
query.from(request.pageParams.getFrom())

View File

@ -69,7 +69,6 @@ public class GetRecordsAction extends Action<GetRecordsAction.Request, GetRecord
public static final ParseField RECORD_SCORE_FILTER = new ParseField("record_score");
public static final ParseField SORT = new ParseField("sort");
public static final ParseField DESCENDING = new ParseField("desc");
public static final ParseField PARTITION_VALUE = new ParseField("partition_value");
private static final ObjectParser<Request, Void> PARSER = new ObjectParser<>(NAME, Request::new);
@ -77,7 +76,6 @@ public class GetRecordsAction extends Action<GetRecordsAction.Request, GetRecord
PARSER.declareString((request, jobId) -> request.jobId = jobId, Job.ID);
PARSER.declareStringOrNull(Request::setStart, START);
PARSER.declareStringOrNull(Request::setEnd, END);
PARSER.declareString(Request::setPartitionValue, PARTITION_VALUE);
PARSER.declareString(Request::setSort, SORT);
PARSER.declareBoolean(Request::setDecending, DESCENDING);
PARSER.declareBoolean(Request::setIncludeInterim, INCLUDE_INTERIM);
@ -101,7 +99,6 @@ public class GetRecordsAction extends Action<GetRecordsAction.Request, GetRecord
private double recordScoreFilter = 0.0;
private String sort = Influencer.INFLUENCER_SCORE.getPreferredName();
private boolean decending = false;
private String partitionValue;
Request() {
}
@ -169,14 +166,6 @@ public class GetRecordsAction extends Action<GetRecordsAction.Request, GetRecord
this.sort = ExceptionsHelper.requireNonNull(sort, SORT.getPreferredName());
}
public String getPartitionValue() {
return partitionValue;
}
public void setPartitionValue(String partitionValue) {
this.partitionValue = ExceptionsHelper.requireNonNull(partitionValue, PARTITION_VALUE.getPreferredName());
}
@Override
public ActionRequestValidationException validate() {
return null;
@ -193,7 +182,6 @@ public class GetRecordsAction extends Action<GetRecordsAction.Request, GetRecord
sort = in.readOptionalString();
decending = in.readBoolean();
recordScoreFilter = in.readDouble();
partitionValue = in.readOptionalString();
}
@Override
@ -207,7 +195,6 @@ public class GetRecordsAction extends Action<GetRecordsAction.Request, GetRecord
out.writeOptionalString(sort);
out.writeBoolean(decending);
out.writeDouble(recordScoreFilter);
out.writeOptionalString(partitionValue);
}
@Override
@ -221,17 +208,13 @@ public class GetRecordsAction extends Action<GetRecordsAction.Request, GetRecord
builder.field(RECORD_SCORE_FILTER.getPreferredName(), recordScoreFilter);
builder.field(INCLUDE_INTERIM.getPreferredName(), includeInterim);
builder.field(PageParams.PAGE.getPreferredName(), pageParams);
if (partitionValue != null) {
builder.field(PARTITION_VALUE.getPreferredName(), partitionValue);
}
builder.endObject();
return builder;
}
@Override
public int hashCode() {
return Objects.hash(jobId, start, end, sort, decending, recordScoreFilter, includeInterim,
pageParams, partitionValue);
return Objects.hash(jobId, start, end, sort, decending, recordScoreFilter, includeInterim, pageParams);
}
@Override
@ -250,8 +233,7 @@ public class GetRecordsAction extends Action<GetRecordsAction.Request, GetRecord
Objects.equals(decending, other.decending) &&
Objects.equals(recordScoreFilter, other.recordScoreFilter) &&
Objects.equals(includeInterim, other.includeInterim) &&
Objects.equals(pageParams, other.pageParams) &&
Objects.equals(partitionValue, other.partitionValue);
Objects.equals(pageParams, other.pageParams);
}
}

View File

@ -71,9 +71,6 @@ public class RestGetBucketsAction extends BaseRestHandler {
request.setAnomalyScore(
Double.parseDouble(restRequest.param(GetBucketsAction.Request.ANOMALY_SCORE.getPreferredName(), "0.0")));
}
if (restRequest.hasParam(GetBucketsAction.Request.PARTITION_VALUE.getPreferredName())) {
request.setPartitionValue(restRequest.param(GetBucketsAction.Request.PARTITION_VALUE.getPreferredName()));
}
// single and multiple bucket options
request.setExpand(restRequest.paramAsBoolean(GetBucketsAction.Request.EXPAND.getPreferredName(), false));

View File

@ -50,10 +50,6 @@ public class RestGetRecordsAction extends BaseRestHandler {
request.setSort(restRequest.param(GetRecordsAction.Request.SORT.getPreferredName(),
AnomalyRecord.RECORD_SCORE.getPreferredName()));
request.setDecending(restRequest.paramAsBoolean(GetRecordsAction.Request.DESCENDING.getPreferredName(), true));
String partitionValue = restRequest.param(GetRecordsAction.Request.PARTITION_VALUE.getPreferredName());
if (partitionValue != null) {
request.setPartitionValue(partitionValue);
}
}
return channel -> client.execute(GetRecordsAction.INSTANCE, request, new RestToXContentListener<>(channel));

View File

@ -19,9 +19,6 @@ public class GetBucketActionRequestTests extends AbstractStreamableXContentTestC
if (randomBoolean()) {
request.setTimestamp(String.valueOf(randomLong()));
} else {
if (randomBoolean()) {
request.setPartitionValue(randomAlphaOfLengthBetween(1, 20));
}
if (randomBoolean()) {
request.setStart(String.valueOf(randomLong()));
}
@ -34,9 +31,6 @@ public class GetBucketActionRequestTests extends AbstractStreamableXContentTestC
if (randomBoolean()) {
request.setAnomalyScore(randomDouble());
}
if (randomBoolean()) {
request.setPartitionValue(randomAlphaOfLengthBetween(1, 20));
}
if (randomBoolean()) {
int from = randomInt(PageParams.MAX_FROM_SIZE_SUM);
int maxSize = PageParams.MAX_FROM_SIZE_SUM - from;

View File

@ -28,9 +28,6 @@ public class GetRecordsActionRequestTests extends AbstractStreamableXContentTest
String end = randomBoolean() ? randomAlphaOfLengthBetween(1, 20) : String.valueOf(randomNonNegativeLong());
request.setEnd(end);
}
if (randomBoolean()) {
request.setPartitionValue(randomAlphaOfLengthBetween(1, 20));
}
if (randomBoolean()) {
request.setSort(randomAlphaOfLengthBetween(1, 20));
}

View File

@ -27,10 +27,6 @@
"type": "boolean",
"description" : "Include interim results"
},
"partition_value": {
"type": "string",
"description": "If expand is true filter anomaly records by the partitionFieldValue"
},
"from": {
"type": "int",
"description": "skips a number of buckets"

View File

@ -36,10 +36,6 @@
"record_score": {
"type": "double"
},
"partition_value": {
"type": "string",
"description": "Filter anomaly records by the partitionFieldValue"
},
"sort": {
"type": "string",
"description": "Sort records by a particular field"