@Override protected boolean doEquals(RangeQueryBuilder other) { String timeZoneId = timeZone == null ? null : timeZone.getID(); String formatString = format == null ? null : format.pattern(); return Objects.equals(fieldName, other.fieldName) && Objects.equals(from, other.from) && Objects.equals(to, other.to) && Objects.equals(timeZoneId, other.timeZone()) && Objects.equals(includeLower, other.includeLower) && Objects.equals(includeUpper, other.includeUpper) && Objects.equals(formatString, other.format()); } }
/** * By default, range queries on date/time need use the format of the source to parse the literal. So we need to specify * that the literal has "date_time" format * @param literal * @param rangeQueryBuilder * @return */ private static RangeQueryBuilder addFormatIfNecessary(LiteralExpression literal, RangeQueryBuilder rangeQueryBuilder) { if (literal.value() instanceof GregorianCalendar) { rangeQueryBuilder.format("date_time"); } return rangeQueryBuilder; }
@Override protected boolean doEquals(RangeQueryBuilder other) { String timeZoneId = timeZone == null ? null : timeZone.getID(); String formatString = format == null ? null : format.format(); return Objects.equals(fieldName, other.fieldName) && Objects.equals(from, other.from) && Objects.equals(to, other.to) && Objects.equals(timeZoneId, other.timeZone()) && Objects.equals(includeLower, other.includeLower) && Objects.equals(includeUpper, other.includeUpper) && Objects.equals(formatString, other.format()); } }
@Override protected boolean doEquals(RangeQueryBuilder other) { String timeZoneId = timeZone == null ? null : timeZone.getID(); String formatString = format == null ? null : format.format(); return Objects.equals(fieldName, other.fieldName) && Objects.equals(from, other.from) && Objects.equals(to, other.to) && Objects.equals(timeZoneId, other.timeZone()) && Objects.equals(includeLower, other.includeLower) && Objects.equals(includeUpper, other.includeUpper) && Objects.equals(formatString, other.format()); } }
@JsonIgnore @Override public QueryBuilder getEsFilter() { if (getSelection().isEmpty()) { return null; } BoolQueryBuilder ret = QueryBuilders.boolQuery(); for (String sel : getSelection()) { RangeQueryBuilder rangeFilter = QueryBuilders.rangeQuery(getField()); DateTime from = convertStringToDate(sel); DateTime to = DateHelper.plusDuration(from, getInterval()); rangeFilter.gte(from.getMillis()).lt(to.getMillis()).format(ElasticSearchConstants.EPOCH_MILLIS_FORMAT); ret.should(rangeFilter); } return ret; }
queryBuilder.format(format);
.format("epoch_millis") .from(startTime) .to(endTime)
.format("epoch_millis") .from(startTime) .to(endTime)
rangeQuery.queryName(queryName); if (format != null) { rangeQuery.format(format);
rangeQuery.queryName(queryName); if (format != null) { rangeQuery.format(format);
rangeQuery.queryName(queryName); if (format != null) { rangeQuery.format(format);
rangeQuery.queryName(queryName); if (format != null) { rangeQuery.format(format);