Rename epochStart/epochEnd to start/end in result query builders
Original commit: elastic/x-pack-elasticsearch@f4fdd64278
This commit is contained in:
parent
2898e3c421
commit
ec5aa34d17
|
@ -319,7 +319,7 @@ extends Action<GetInfluencersAction.Request, GetInfluencersAction.Response, GetI
|
||||||
@Override
|
@Override
|
||||||
protected void doExecute(Request request, ActionListener<Response> listener) {
|
protected void doExecute(Request request, ActionListener<Response> listener) {
|
||||||
InfluencersQueryBuilder.InfluencersQuery query = new InfluencersQueryBuilder().includeInterim(request.includeInterim)
|
InfluencersQueryBuilder.InfluencersQuery query = new InfluencersQueryBuilder().includeInterim(request.includeInterim)
|
||||||
.epochStart(request.start).epochEnd(request.end).from(request.pageParams.getFrom()).size(request.pageParams.getSize())
|
.start(request.start).end(request.end).from(request.pageParams.getFrom()).size(request.pageParams.getSize())
|
||||||
.anomalyScoreThreshold(request.anomalyScoreFilter).sortField(request.sort).sortDescending(request.decending).build();
|
.anomalyScoreThreshold(request.anomalyScoreFilter).sortField(request.sort).sortDescending(request.decending).build();
|
||||||
|
|
||||||
QueryPage<Influencer> page = jobProvider.influencers(request.jobId, query);
|
QueryPage<Influencer> page = jobProvider.influencers(request.jobId, query);
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.prelert.job.persistence;
|
package org.elasticsearch.xpack.prelert.job.persistence;
|
||||||
|
|
||||||
import org.elasticsearch.xpack.prelert.job.results.Bucket;
|
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
|
import org.elasticsearch.xpack.prelert.job.results.Bucket;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -23,10 +23,10 @@ import java.util.Objects;
|
||||||
* this value. Default = 0.0</li>
|
* this value. Default = 0.0</li>
|
||||||
* <li>normalizedProbabilityThreshold- Return only buckets with a
|
* <li>normalizedProbabilityThreshold- Return only buckets with a
|
||||||
* maxNormalizedProbability >= this value. Default = 0.0</li>
|
* maxNormalizedProbability >= this value. Default = 0.0</li>
|
||||||
* <li>epochStart- The start bucket time. A bucket with this timestamp will be
|
* <li>start- The start bucket time. A bucket with this timestamp will be
|
||||||
* included in the results. If 0 all buckets up to <code>endEpochMs</code> are
|
* included in the results. If 0 all buckets up to <code>endEpochMs</code> are
|
||||||
* returned. Default = -1</li>
|
* returned. Default = -1</li>
|
||||||
* <li>epochEnd- The end bucket timestamp buckets up to but NOT including this
|
* <li>end- The end bucket timestamp buckets up to but NOT including this
|
||||||
* timestamp are returned. If 0 all buckets from <code>startEpochMs</code> are
|
* timestamp are returned. If 0 all buckets from <code>startEpochMs</code> are
|
||||||
* returned. Default = -1</li>
|
* returned. Default = -1</li>
|
||||||
* <li>partitionValue Set the bucket's max normalised probability to this
|
* <li>partitionValue Set the bucket's max normalised probability to this
|
||||||
|
@ -92,7 +92,7 @@ public final class BucketsQueryBuilder {
|
||||||
* If startTime <= 0 the parameter is not set
|
* If startTime <= 0 the parameter is not set
|
||||||
*/
|
*/
|
||||||
public BucketsQueryBuilder epochStart(String startTime) {
|
public BucketsQueryBuilder epochStart(String startTime) {
|
||||||
bucketsQuery.epochStart = startTime;
|
bucketsQuery.start = startTime;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ public final class BucketsQueryBuilder {
|
||||||
* If endTime <= 0 the parameter is not set
|
* If endTime <= 0 the parameter is not set
|
||||||
*/
|
*/
|
||||||
public BucketsQueryBuilder epochEnd(String endTime) {
|
public BucketsQueryBuilder epochEnd(String endTime) {
|
||||||
bucketsQuery.epochEnd = endTime;
|
bucketsQuery.end = endTime;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,8 +120,8 @@ public final class BucketsQueryBuilder {
|
||||||
private boolean includeInterim = false;
|
private boolean includeInterim = false;
|
||||||
private double anomalyScoreFilter = 0.0d;
|
private double anomalyScoreFilter = 0.0d;
|
||||||
private double normalizedProbability = 0.0d;
|
private double normalizedProbability = 0.0d;
|
||||||
private String epochStart;
|
private String start;
|
||||||
private String epochEnd;
|
private String end;
|
||||||
private String partitionValue = null;
|
private String partitionValue = null;
|
||||||
private String sortField = Bucket.TIMESTAMP.getPreferredName();
|
private String sortField = Bucket.TIMESTAMP.getPreferredName();
|
||||||
private boolean sortDescending = false;
|
private boolean sortDescending = false;
|
||||||
|
@ -150,12 +150,12 @@ public final class BucketsQueryBuilder {
|
||||||
return normalizedProbability;
|
return normalizedProbability;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEpochStart() {
|
public String getStart() {
|
||||||
return epochStart;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEpochEnd() {
|
public String getEnd() {
|
||||||
return epochEnd;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -175,7 +175,7 @@ public final class BucketsQueryBuilder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(from, size, expand, includeInterim, anomalyScoreFilter, normalizedProbability, epochStart, epochEnd,
|
return Objects.hash(from, size, expand, includeInterim, anomalyScoreFilter, normalizedProbability, start, end,
|
||||||
partitionValue, sortField, sortDescending);
|
partitionValue, sortField, sortDescending);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,8 +197,8 @@ public final class BucketsQueryBuilder {
|
||||||
Objects.equals(size, other.size) &&
|
Objects.equals(size, other.size) &&
|
||||||
Objects.equals(expand, other.expand) &&
|
Objects.equals(expand, other.expand) &&
|
||||||
Objects.equals(includeInterim, other.includeInterim) &&
|
Objects.equals(includeInterim, other.includeInterim) &&
|
||||||
Objects.equals(epochStart, other.epochStart) &&
|
Objects.equals(start, other.start) &&
|
||||||
Objects.equals(epochEnd, other.epochEnd) &&
|
Objects.equals(end, other.end) &&
|
||||||
Objects.equals(anomalyScoreFilter, other.anomalyScoreFilter) &&
|
Objects.equals(anomalyScoreFilter, other.anomalyScoreFilter) &&
|
||||||
Objects.equals(normalizedProbability, other.normalizedProbability) &&
|
Objects.equals(normalizedProbability, other.normalizedProbability) &&
|
||||||
Objects.equals(partitionValue, other.partitionValue) &&
|
Objects.equals(partitionValue, other.partitionValue) &&
|
||||||
|
|
|
@ -273,7 +273,7 @@ public class ElasticsearchJobProvider implements JobProvider {
|
||||||
public QueryPage<Bucket> buckets(String jobId, BucketsQuery query)
|
public QueryPage<Bucket> buckets(String jobId, BucketsQuery query)
|
||||||
throws ResourceNotFoundException {
|
throws ResourceNotFoundException {
|
||||||
QueryBuilder fb = new ResultsFilterBuilder()
|
QueryBuilder fb = new ResultsFilterBuilder()
|
||||||
.timeRange(ElasticsearchMappings.ES_TIMESTAMP, query.getEpochStart(), query.getEpochEnd())
|
.timeRange(ElasticsearchMappings.ES_TIMESTAMP, query.getStart(), query.getEnd())
|
||||||
.score(Bucket.ANOMALY_SCORE.getPreferredName(), query.getAnomalyScoreFilter())
|
.score(Bucket.ANOMALY_SCORE.getPreferredName(), query.getAnomalyScoreFilter())
|
||||||
.score(Bucket.MAX_NORMALIZED_PROBABILITY.getPreferredName(), query.getNormalizedProbability())
|
.score(Bucket.MAX_NORMALIZED_PROBABILITY.getPreferredName(), query.getNormalizedProbability())
|
||||||
.interim(Bucket.IS_INTERIM.getPreferredName(), query.isIncludeInterim())
|
.interim(Bucket.IS_INTERIM.getPreferredName(), query.isIncludeInterim())
|
||||||
|
@ -292,7 +292,7 @@ public class ElasticsearchJobProvider implements JobProvider {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
List<PerPartitionMaxProbabilities> scores =
|
List<PerPartitionMaxProbabilities> scores =
|
||||||
partitionMaxNormalisedProbabilities(jobId, query.getEpochStart(), query.getEpochEnd(), query.getPartitionValue());
|
partitionMaxNormalisedProbabilities(jobId, query.getStart(), query.getEnd(), query.getPartitionValue());
|
||||||
|
|
||||||
mergePartitionScoresIntoBucket(scores, buckets.results(), query.getPartitionValue());
|
mergePartitionScoresIntoBucket(scores, buckets.results(), query.getPartitionValue());
|
||||||
|
|
||||||
|
@ -630,7 +630,7 @@ public class ElasticsearchJobProvider implements JobProvider {
|
||||||
public QueryPage<AnomalyRecord> records(String jobId, RecordsQueryBuilder.RecordsQuery query)
|
public QueryPage<AnomalyRecord> records(String jobId, RecordsQueryBuilder.RecordsQuery query)
|
||||||
throws ResourceNotFoundException {
|
throws ResourceNotFoundException {
|
||||||
QueryBuilder fb = new ResultsFilterBuilder()
|
QueryBuilder fb = new ResultsFilterBuilder()
|
||||||
.timeRange(ElasticsearchMappings.ES_TIMESTAMP, query.getEpochStart(), query.getEpochEnd())
|
.timeRange(ElasticsearchMappings.ES_TIMESTAMP, query.getStart(), query.getEnd())
|
||||||
.score(AnomalyRecord.ANOMALY_SCORE.getPreferredName(), query.getAnomalyScoreThreshold())
|
.score(AnomalyRecord.ANOMALY_SCORE.getPreferredName(), query.getAnomalyScoreThreshold())
|
||||||
.score(AnomalyRecord.NORMALIZED_PROBABILITY.getPreferredName(), query.getNormalizedProbabilityThreshold())
|
.score(AnomalyRecord.NORMALIZED_PROBABILITY.getPreferredName(), query.getNormalizedProbabilityThreshold())
|
||||||
.interim(AnomalyRecord.IS_INTERIM.getPreferredName(), query.isIncludeInterim())
|
.interim(AnomalyRecord.IS_INTERIM.getPreferredName(), query.isIncludeInterim())
|
||||||
|
@ -711,7 +711,7 @@ public class ElasticsearchJobProvider implements JobProvider {
|
||||||
@Override
|
@Override
|
||||||
public QueryPage<Influencer> influencers(String jobId, InfluencersQuery query) throws ResourceNotFoundException {
|
public QueryPage<Influencer> influencers(String jobId, InfluencersQuery query) throws ResourceNotFoundException {
|
||||||
QueryBuilder fb = new ResultsFilterBuilder()
|
QueryBuilder fb = new ResultsFilterBuilder()
|
||||||
.timeRange(ElasticsearchMappings.ES_TIMESTAMP, query.getEpochStart(), query.getEpochEnd())
|
.timeRange(ElasticsearchMappings.ES_TIMESTAMP, query.getStart(), query.getEnd())
|
||||||
.score(Bucket.ANOMALY_SCORE.getPreferredName(), query.getAnomalyScoreFilter())
|
.score(Bucket.ANOMALY_SCORE.getPreferredName(), query.getAnomalyScoreFilter())
|
||||||
.interim(Bucket.IS_INTERIM.getPreferredName(), query.isIncludeInterim())
|
.interim(Bucket.IS_INTERIM.getPreferredName(), query.isIncludeInterim())
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -10,23 +10,20 @@ import org.elasticsearch.xpack.prelert.job.results.Influencer;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One time query builder for buckets.
|
* One time query builder for influencers.
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>From- Skip the first N Buckets. This parameter is for paging if not
|
* <li>From- Skip the first N Influencers. This parameter is for paging if not
|
||||||
* required set to 0. Default = 0</li>
|
* required set to 0. Default = 0</li>
|
||||||
* <li>Size- Take only this number of Buckets. Default =
|
* <li>Size- Take only this number of Influencers. Default =
|
||||||
* {@value DEFAULT_SIZE}</li>
|
* {@value DEFAULT_SIZE}</li>
|
||||||
* <li>Expand- Include anomaly records. Default= false</li>
|
|
||||||
* <li>IncludeInterim- Include interim results. Default = false</li>
|
* <li>IncludeInterim- Include interim results. Default = false</li>
|
||||||
* <li>anomalyScoreThreshold- Return only buckets with an anomalyScore >=
|
* <li>anomalyScoreThreshold- Return only influencers with an anomalyScore >=
|
||||||
* this value. Default = 0.0</li>
|
* this value. Default = 0.0</li>
|
||||||
* <li>normalizedProbabilityThreshold- Return only buckets with a
|
* <li>start- The start influencer time. An influencer with this timestamp will be
|
||||||
* maxNormalizedProbability >= this value. Default = 0.0</li>
|
* included in the results. If 0 all influencers up to <code>end</code> are
|
||||||
* <li>epochStart- The start bucket time. A bucket with this timestamp will be
|
|
||||||
* included in the results. If 0 all buckets up to <code>endEpochMs</code> are
|
|
||||||
* returned. Default = -1</li>
|
* returned. Default = -1</li>
|
||||||
* <li>epochEnd- The end bucket timestamp buckets up to but NOT including this
|
* <li>end- The end influencer timestamp. Influencers up to but NOT including this
|
||||||
* timestamp are returned. If 0 all buckets from <code>startEpochMs</code> are
|
* timestamp are returned. If 0 all influencers from <code>start</code> are
|
||||||
* returned. Default = -1</li>
|
* returned. Default = -1</li>
|
||||||
* <li>partitionValue Set the bucket's max normalised probability to this
|
* <li>partitionValue Set the bucket's max normalised probability to this
|
||||||
* partition field value's max normalised probability. Default = null</li>
|
* partition field value's max normalised probability. Default = null</li>
|
||||||
|
@ -70,16 +67,16 @@ public final class InfluencersQueryBuilder {
|
||||||
/**
|
/**
|
||||||
* If startTime >= 0 the parameter is not set
|
* If startTime >= 0 the parameter is not set
|
||||||
*/
|
*/
|
||||||
public InfluencersQueryBuilder epochStart(String startTime) {
|
public InfluencersQueryBuilder start(String startTime) {
|
||||||
influencersQuery.epochStart = startTime;
|
influencersQuery.start = startTime;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If endTime >= 0 the parameter is not set
|
* If endTime >= 0 the parameter is not set
|
||||||
*/
|
*/
|
||||||
public InfluencersQueryBuilder epochEnd(String endTime) {
|
public InfluencersQueryBuilder end(String endTime) {
|
||||||
influencersQuery.epochEnd = endTime;
|
influencersQuery.end = endTime;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,8 +94,8 @@ public final class InfluencersQueryBuilder {
|
||||||
private int size = DEFAULT_SIZE;
|
private int size = DEFAULT_SIZE;
|
||||||
private boolean includeInterim = false;
|
private boolean includeInterim = false;
|
||||||
private double anomalyScoreFilter = 0.0d;
|
private double anomalyScoreFilter = 0.0d;
|
||||||
private String epochStart;
|
private String start;
|
||||||
private String epochEnd;
|
private String end;
|
||||||
private String sortField = Influencer.ANOMALY_SCORE.getPreferredName();
|
private String sortField = Influencer.ANOMALY_SCORE.getPreferredName();
|
||||||
private boolean sortDescending = false;
|
private boolean sortDescending = false;
|
||||||
|
|
||||||
|
@ -118,12 +115,12 @@ public final class InfluencersQueryBuilder {
|
||||||
return anomalyScoreFilter;
|
return anomalyScoreFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEpochStart() {
|
public String getStart() {
|
||||||
return epochStart;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEpochEnd() {
|
public String getEnd() {
|
||||||
return epochEnd;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSortField() {
|
public String getSortField() {
|
||||||
|
@ -136,8 +133,7 @@ public final class InfluencersQueryBuilder {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(from, size, includeInterim, anomalyScoreFilter, epochStart, epochEnd,
|
return Objects.hash(from, size, includeInterim, anomalyScoreFilter, start, end, sortField, sortDescending);
|
||||||
sortField, sortDescending);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -157,8 +153,8 @@ public final class InfluencersQueryBuilder {
|
||||||
return Objects.equals(from, other.from) &&
|
return Objects.equals(from, other.from) &&
|
||||||
Objects.equals(size, other.size) &&
|
Objects.equals(size, other.size) &&
|
||||||
Objects.equals(includeInterim, other.includeInterim) &&
|
Objects.equals(includeInterim, other.includeInterim) &&
|
||||||
Objects.equals(epochStart, other.epochStart) &&
|
Objects.equals(start, other.start) &&
|
||||||
Objects.equals(epochEnd, other.epochEnd) &&
|
Objects.equals(end, other.end) &&
|
||||||
Objects.equals(anomalyScoreFilter, other.anomalyScoreFilter) &&
|
Objects.equals(anomalyScoreFilter, other.anomalyScoreFilter) &&
|
||||||
Objects.equals(sortField, other.sortField) &&
|
Objects.equals(sortField, other.sortField) &&
|
||||||
this.sortDescending == other.sortDescending;
|
this.sortDescending == other.sortDescending;
|
||||||
|
|
|
@ -21,92 +21,80 @@ package org.elasticsearch.xpack.prelert.job.persistence;
|
||||||
* this value. Default = 0.0</li>
|
* this value. Default = 0.0</li>
|
||||||
* <li>normalizedProbabilityThreshold. Return only buckets with a
|
* <li>normalizedProbabilityThreshold. Return only buckets with a
|
||||||
* maxNormalizedProbability >= this value. Default = 0.0</li>
|
* maxNormalizedProbability >= this value. Default = 0.0</li>
|
||||||
* <li>epochStart- The start bucket time. A bucket with this timestamp will be
|
* <li>start- The start bucket time. A bucket with this timestamp will be
|
||||||
* included in the results. If 0 all buckets up to <code>endEpochMs</code> are
|
* included in the results. If 0 all buckets up to <code>endEpochMs</code> are
|
||||||
* returned. Default = -1</li>
|
* returned. Default = -1</li>
|
||||||
* <li>epochEnd- The end bucket timestamp buckets up to but NOT including this
|
* <li>end- The end bucket timestamp buckets up to but NOT including this
|
||||||
* timestamp are returned. If 0 all buckets from <code>startEpochMs</code> are
|
* timestamp are returned. If 0 all buckets from <code>startEpochMs</code> are
|
||||||
* returned. Default = -1</li>
|
* returned. Default = -1</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public final class RecordsQueryBuilder
|
public final class RecordsQueryBuilder {
|
||||||
{
|
|
||||||
public static final int DEFAULT_SIZE = 100;
|
public static final int DEFAULT_SIZE = 100;
|
||||||
|
|
||||||
private RecordsQuery recordsQuery = new RecordsQuery();
|
private RecordsQuery recordsQuery = new RecordsQuery();
|
||||||
|
|
||||||
public RecordsQueryBuilder from(int from)
|
public RecordsQueryBuilder from(int from) {
|
||||||
{
|
|
||||||
recordsQuery.from = from;
|
recordsQuery.from = from;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecordsQueryBuilder size(int size)
|
public RecordsQueryBuilder size(int size) {
|
||||||
{
|
|
||||||
recordsQuery.size = size;
|
recordsQuery.size = size;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecordsQueryBuilder epochStart(String startTime)
|
public RecordsQueryBuilder epochStart(String startTime) {
|
||||||
{
|
recordsQuery.start = startTime;
|
||||||
recordsQuery.epochStart = startTime;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecordsQueryBuilder epochEnd(String endTime)
|
public RecordsQueryBuilder epochEnd(String endTime) {
|
||||||
{
|
recordsQuery.end = endTime;
|
||||||
recordsQuery.epochEnd = endTime;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecordsQueryBuilder includeInterim(boolean include)
|
public RecordsQueryBuilder includeInterim(boolean include) {
|
||||||
{
|
|
||||||
recordsQuery.includeInterim = include;
|
recordsQuery.includeInterim = include;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecordsQueryBuilder sortField(String fieldname)
|
public RecordsQueryBuilder sortField(String fieldname) {
|
||||||
{
|
|
||||||
recordsQuery.sortField = fieldname;
|
recordsQuery.sortField = fieldname;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecordsQueryBuilder sortDescending(boolean sortDescending)
|
public RecordsQueryBuilder sortDescending(boolean sortDescending) {
|
||||||
{
|
|
||||||
recordsQuery.sortDescending = sortDescending;
|
recordsQuery.sortDescending = sortDescending;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecordsQueryBuilder anomalyScoreThreshold(double anomalyScoreFilter)
|
public RecordsQueryBuilder anomalyScoreThreshold(double anomalyScoreFilter) {
|
||||||
{
|
|
||||||
recordsQuery.anomalyScoreFilter = anomalyScoreFilter;
|
recordsQuery.anomalyScoreFilter = anomalyScoreFilter;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecordsQueryBuilder normalizedProbability(double normalizedProbability)
|
public RecordsQueryBuilder normalizedProbability(double normalizedProbability) {
|
||||||
{
|
|
||||||
recordsQuery.normalizedProbability = normalizedProbability;
|
recordsQuery.normalizedProbability = normalizedProbability;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecordsQueryBuilder partitionFieldValue(String partitionFieldValue)
|
public RecordsQueryBuilder partitionFieldValue(String partitionFieldValue) {
|
||||||
{
|
|
||||||
recordsQuery.partitionFieldValue = partitionFieldValue;
|
recordsQuery.partitionFieldValue = partitionFieldValue;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecordsQuery build()
|
public RecordsQuery build() {
|
||||||
{
|
|
||||||
return recordsQuery;
|
return recordsQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear()
|
public void clear() {
|
||||||
{
|
|
||||||
recordsQuery = new RecordsQuery();
|
recordsQuery = new RecordsQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RecordsQuery
|
public class RecordsQuery {
|
||||||
{
|
|
||||||
private int from = 0;
|
private int from = 0;
|
||||||
private int size = DEFAULT_SIZE;
|
private int size = DEFAULT_SIZE;
|
||||||
private boolean includeInterim = false;
|
private boolean includeInterim = false;
|
||||||
|
@ -115,58 +103,48 @@ public final class RecordsQueryBuilder
|
||||||
private double anomalyScoreFilter = 0.0d;
|
private double anomalyScoreFilter = 0.0d;
|
||||||
private double normalizedProbability = 0.0d;
|
private double normalizedProbability = 0.0d;
|
||||||
private String partitionFieldValue;
|
private String partitionFieldValue;
|
||||||
private String epochStart;
|
private String start;
|
||||||
private String epochEnd;
|
private String end;
|
||||||
|
|
||||||
|
|
||||||
public int getSize()
|
public int getSize() {
|
||||||
{
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIncludeInterim()
|
public boolean isIncludeInterim() {
|
||||||
{
|
|
||||||
return includeInterim;
|
return includeInterim;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSortField()
|
public String getSortField() {
|
||||||
{
|
|
||||||
return sortField;
|
return sortField;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSortDescending()
|
public boolean isSortDescending() {
|
||||||
{
|
|
||||||
return sortDescending;
|
return sortDescending;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getAnomalyScoreThreshold()
|
public double getAnomalyScoreThreshold() {
|
||||||
{
|
|
||||||
return anomalyScoreFilter;
|
return anomalyScoreFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getNormalizedProbabilityThreshold()
|
public double getNormalizedProbabilityThreshold() {
|
||||||
{
|
|
||||||
return normalizedProbability;
|
return normalizedProbability;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPartitionFieldValue()
|
public String getPartitionFieldValue() {
|
||||||
{
|
|
||||||
return partitionFieldValue;
|
return partitionFieldValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFrom()
|
public int getFrom() {
|
||||||
{
|
|
||||||
return from;
|
return from;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEpochStart()
|
public String getStart() {
|
||||||
{
|
return start;
|
||||||
return epochStart;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEpochEnd()
|
public String getEnd() {
|
||||||
{
|
return end;
|
||||||
return epochEnd;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@ public class BucketsQueryBuilderTests extends ESTestCase {
|
||||||
assertEquals(false, query.isExpand());
|
assertEquals(false, query.isExpand());
|
||||||
assertEquals(0.0, query.getAnomalyScoreFilter(), 0.0001);
|
assertEquals(0.0, query.getAnomalyScoreFilter(), 0.0001);
|
||||||
assertEquals(0.0, query.getNormalizedProbability(), 0.0001);
|
assertEquals(0.0, query.getNormalizedProbability(), 0.0001);
|
||||||
assertNull(query.getEpochStart());
|
assertNull(query.getStart());
|
||||||
assertNull(query.getEpochEnd());
|
assertNull(query.getEnd());
|
||||||
assertEquals("timestamp", query.getSortField());
|
assertEquals("timestamp", query.getSortField());
|
||||||
assertFalse(query.isSortDescending());
|
assertFalse(query.isSortDescending());
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ public class BucketsQueryBuilderTests extends ESTestCase {
|
||||||
assertEquals(true, query.isExpand());
|
assertEquals(true, query.isExpand());
|
||||||
assertEquals(50.0d, query.getAnomalyScoreFilter(), 0.00001);
|
assertEquals(50.0d, query.getAnomalyScoreFilter(), 0.00001);
|
||||||
assertEquals(70.0d, query.getNormalizedProbability(), 0.00001);
|
assertEquals(70.0d, query.getNormalizedProbability(), 0.00001);
|
||||||
assertEquals("1000", query.getEpochStart());
|
assertEquals("1000", query.getStart());
|
||||||
assertEquals("2000", query.getEpochEnd());
|
assertEquals("2000", query.getEnd());
|
||||||
assertEquals("foo", query.getPartitionValue());
|
assertEquals("foo", query.getPartitionValue());
|
||||||
assertEquals("anomalyScore", query.getSortField());
|
assertEquals("anomalyScore", query.getSortField());
|
||||||
assertTrue(query.isSortDescending());
|
assertTrue(query.isSortDescending());
|
||||||
|
|
|
@ -762,7 +762,7 @@ public class ElasticsearchJobProviderTests extends ESTestCase {
|
||||||
Client client = clientBuilder.build();
|
Client client = clientBuilder.build();
|
||||||
ElasticsearchJobProvider provider = createProvider(client);
|
ElasticsearchJobProvider provider = createProvider(client);
|
||||||
|
|
||||||
InfluencersQuery query = new InfluencersQueryBuilder().from(from).size(size).epochStart("0").epochEnd("0").sortField("sort")
|
InfluencersQuery query = new InfluencersQueryBuilder().from(from).size(size).start("0").end("0").sortField("sort")
|
||||||
.sortDescending(true).anomalyScoreThreshold(0.0).includeInterim(true).build();
|
.sortDescending(true).anomalyScoreThreshold(0.0).includeInterim(true).build();
|
||||||
QueryPage<Influencer> page = provider.influencers(jobId, query);
|
QueryPage<Influencer> page = provider.influencers(jobId, query);
|
||||||
assertEquals(2L, page.count());
|
assertEquals(2L, page.count());
|
||||||
|
|
|
@ -17,8 +17,8 @@ public class InfluencersQueryBuilderTests extends ESTestCase {
|
||||||
assertEquals(InfluencersQueryBuilder.DEFAULT_SIZE, query.getSize());
|
assertEquals(InfluencersQueryBuilder.DEFAULT_SIZE, query.getSize());
|
||||||
assertEquals(false, query.isIncludeInterim());
|
assertEquals(false, query.isIncludeInterim());
|
||||||
assertEquals(0.0, query.getAnomalyScoreFilter(), 0.0001);
|
assertEquals(0.0, query.getAnomalyScoreFilter(), 0.0001);
|
||||||
assertNull(query.getEpochStart());
|
assertNull(query.getStart());
|
||||||
assertNull(query.getEpochEnd());
|
assertNull(query.getEnd());
|
||||||
assertEquals(Influencer.ANOMALY_SCORE.getPreferredName(), query.getSortField());
|
assertEquals(Influencer.ANOMALY_SCORE.getPreferredName(), query.getSortField());
|
||||||
assertFalse(query.isSortDescending());
|
assertFalse(query.isSortDescending());
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ public class InfluencersQueryBuilderTests extends ESTestCase {
|
||||||
.size(40)
|
.size(40)
|
||||||
.includeInterim(true)
|
.includeInterim(true)
|
||||||
.anomalyScoreThreshold(50.0d)
|
.anomalyScoreThreshold(50.0d)
|
||||||
.epochStart("1000")
|
.start("1000")
|
||||||
.epochEnd("2000")
|
.end("2000")
|
||||||
.sortField("anomalyScore")
|
.sortField("anomalyScore")
|
||||||
.sortDescending(true)
|
.sortDescending(true)
|
||||||
.build();
|
.build();
|
||||||
|
@ -39,8 +39,8 @@ public class InfluencersQueryBuilderTests extends ESTestCase {
|
||||||
assertEquals(40, query.getSize());
|
assertEquals(40, query.getSize());
|
||||||
assertEquals(true, query.isIncludeInterim());
|
assertEquals(true, query.isIncludeInterim());
|
||||||
assertEquals(50.0d, query.getAnomalyScoreFilter(), 0.00001);
|
assertEquals(50.0d, query.getAnomalyScoreFilter(), 0.00001);
|
||||||
assertEquals("1000", query.getEpochStart());
|
assertEquals("1000", query.getStart());
|
||||||
assertEquals("2000", query.getEpochEnd());
|
assertEquals("2000", query.getEnd());
|
||||||
assertEquals("anomalyScore", query.getSortField());
|
assertEquals("anomalyScore", query.getSortField());
|
||||||
assertTrue(query.isSortDescending());
|
assertTrue(query.isSortDescending());
|
||||||
}
|
}
|
||||||
|
@ -51,16 +51,16 @@ public class InfluencersQueryBuilderTests extends ESTestCase {
|
||||||
.size(40)
|
.size(40)
|
||||||
.includeInterim(true)
|
.includeInterim(true)
|
||||||
.anomalyScoreThreshold(50.0d)
|
.anomalyScoreThreshold(50.0d)
|
||||||
.epochStart("1000")
|
.start("1000")
|
||||||
.epochEnd("2000");
|
.end("2000");
|
||||||
|
|
||||||
InfluencersQueryBuilder query2 = new InfluencersQueryBuilder()
|
InfluencersQueryBuilder query2 = new InfluencersQueryBuilder()
|
||||||
.from(20)
|
.from(20)
|
||||||
.size(40)
|
.size(40)
|
||||||
.includeInterim(true)
|
.includeInterim(true)
|
||||||
.anomalyScoreThreshold(50.0d)
|
.anomalyScoreThreshold(50.0d)
|
||||||
.epochStart("1000")
|
.start("1000")
|
||||||
.epochEnd("2000");
|
.end("2000");
|
||||||
|
|
||||||
assertEquals(query.build(), query2.build());
|
assertEquals(query.build(), query2.build());
|
||||||
assertEquals(query.build().hashCode(), query2.build().hashCode());
|
assertEquals(query.build().hashCode(), query2.build().hashCode());
|
||||||
|
@ -71,8 +71,8 @@ public class InfluencersQueryBuilderTests extends ESTestCase {
|
||||||
.size(40)
|
.size(40)
|
||||||
.includeInterim(true)
|
.includeInterim(true)
|
||||||
.anomalyScoreThreshold(50.0d)
|
.anomalyScoreThreshold(50.0d)
|
||||||
.epochStart("1000")
|
.start("1000")
|
||||||
.epochEnd("2000");
|
.end("2000");
|
||||||
assertEquals(query.build(), query2.build());
|
assertEquals(query.build(), query2.build());
|
||||||
|
|
||||||
query2.clear();
|
query2.clear();
|
||||||
|
@ -80,8 +80,8 @@ public class InfluencersQueryBuilderTests extends ESTestCase {
|
||||||
.size(40)
|
.size(40)
|
||||||
.includeInterim(true)
|
.includeInterim(true)
|
||||||
.anomalyScoreThreshold(50.1d)
|
.anomalyScoreThreshold(50.1d)
|
||||||
.epochStart("1000")
|
.start("1000")
|
||||||
.epochEnd("2000");
|
.end("2000");
|
||||||
assertFalse(query.build().equals(query2.build()));
|
assertFalse(query.build().equals(query2.build()));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue