2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 Amdocs
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.onap.aai.sa.searchdbabstraction.searchapi;
23 import com.fasterxml.jackson.annotation.JsonProperty;
26 * An example of elasticsearch date_histogram aggregation:
34 * "date_histogram" : {
36 * "interval" : "month"
44 public class DateHistogramAggregation extends AbstractAggregation {
46 private String interval;
48 private String format;
50 @JsonProperty("time-zone")
51 private String timeZone;
54 public String getInterval() {
58 public void setInterval(String interval) {
59 this.interval = interval;
62 public String getTimeZone() {
66 public String getFormat() {
70 public void setFormat(String format) {
74 public void setTimeZone(String timeZone) {
75 this.timeZone = timeZone;
79 public String toElasticSearch() {
80 StringBuilder sb = new StringBuilder();
82 sb.append("\"date_histogram\": {\"field\": \"");
85 if (interval != null) {
86 sb.append(", \"interval\": \"");
91 sb.append(", \"format\": \"");
95 if (timeZone != null) {
96 sb.append(", \"time_zone\": \"");
101 sb.append(", \"size\": ");
104 if (minThreshold != null) {
105 sb.append(", \"min_doc_count\": ").append(minThreshold);
109 return sb.toString();
113 public String toString() {
114 return "DateHistogramAggregation: [field=" + field + ", interval=" + interval + ", format=" + format
115 + ", timeZone=" + timeZone + ", size=" + size + " minThreshold=" + minThreshold;