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:
32 * "date_histogram" : {
34 * "interval" : "month"
42 public class DateHistogramAggregation extends AbstractAggregation {
44 private String interval;
46 private String format;
48 @JsonProperty("time-zone")
49 private String timeZone;
52 public String getInterval() {
56 public void setInterval(String interval) {
57 this.interval = interval;
60 public String getTimeZone() {
64 public String getFormat() {
68 public void setFormat(String format) {
72 public void setTimeZone(String timeZone) {
73 this.timeZone = timeZone;
77 public String toElasticSearch() {
78 StringBuilder sb = new StringBuilder();
80 sb.append("\"date_histogram\": {\"field\": \"");
83 if (interval != null) {
84 sb.append(", \"interval\": \"");
89 sb.append(", \"format\": \"");
93 if (timeZone != null) {
94 sb.append(", \"time_zone\": \"");
99 sb.append(", \"size\": ");
102 if (minThreshold != null) {
103 sb.append(", \"min_doc_count\": ").append(minThreshold);
107 return sb.toString();
111 public String toString() {
112 return "DateHistogramAggregation: [field=" + field + ", interval=" + interval + ", format="
113 + format + ", timeZone=" + timeZone + ", size=" + size + " minThreshold=" + minThreshold;