001/*
002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Benoit Delbosc
018 */
019package org.nuxeo.ecm.platform.query.api;
020
021import java.util.List;
022import java.util.Map;
023
024/**
025 * @since 6.0
026 */
027public interface Aggregate<B extends Bucket> {
028    /**
029     * The aggregate identifier.
030     */
031    String getId();
032
033    /**
034     * Type of aggregation.
035     */
036    String getType();
037
038    /**
039     * Nuxeo field to aggregate.
040     */
041    String getField();
042
043    /**
044     * Properties of the aggregate.
045     */
046    Map<String, String> getProperties();
047
048    /**
049     * Range definition for aggregate of type range.
050     */
051    List<AggregateRangeDefinition> getRanges();
052
053    /**
054     * Date Range definition for aggregate of type date range.
055     */
056    List<AggregateRangeDateDefinition> getDateRanges();
057
058    /**
059     * The selection filter that is going to be applied to the main query as a post filter.
060     */
061    List<String> getSelection();
062
063    void setSelection(List<String> selection);
064
065    /**
066     * The aggregate results.
067     */
068    List<B> getBuckets();
069
070    void setBuckets(List<B> buckets);
071
072    Bucket getBucket(final String key);
073
074    boolean hasBucket(final String key);
075
076    void resetSelection();
077
078    /**
079     * The regular list of buckets plus buckets with doc count at 0 for selected buckets which are not returned from es
080     * post filtering.
081     */
082    List<Bucket> getExtendedBuckets();
083}