/* SPDX-License-Identifier: Apache-2.0 * * The OpenSearch Contributors require contributions made to * this file be licensed under the Apache-2.0 license or a * compatible open source license. */ /* * Modifications Copyright OpenSearch Contributors. See * GitHub history for details. * * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright * ownership. Elasticsearch B.V. licenses this file to you under * the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ using System; using System.Collections.Generic; using OpenSearch.Net; namespace OpenSearch.Client { public abstract class BucketAggregateBase : AggregateDictionary, IAggregate { protected BucketAggregateBase(IReadOnlyDictionary aggregations) : base(aggregations) { } public IReadOnlyDictionary Meta { get; set; } = EmptyReadOnly.Dictionary; } public class SingleBucketAggregate : BucketAggregateBase { public SingleBucketAggregate(IReadOnlyDictionary aggregations) : base(aggregations) { } /// /// Count of documents in the bucket /// public long DocCount { get; internal set; } } /// /// Aggregation response for a bucket aggregation /// /// public class MultiBucketAggregate : IAggregate where TBucket : IBucket { /// /// The buckets into which results are grouped /// public IReadOnlyCollection Buckets { get; set; } = EmptyReadOnly.Collection; /// public IReadOnlyDictionary Meta { get; set; } = EmptyReadOnly.Dictionary; } /// /// Aggregation response of /// public class CompositeBucketAggregate : MultiBucketAggregate { /// /// The composite key of the last bucket returned /// in the response before any filtering by pipeline aggregations. /// If all buckets are filtered/removed by pipeline aggregations, /// will contain the composite key of the last bucket before filtering. /// public CompositeKey AfterKey { get; set; } } /// /// Intermediate Aggregation response, transformed to a more specific /// aggregation response when requested. /// public class BucketAggregate : IAggregate { public CompositeKey AfterKey { get; set; } public long BgCount { get; set; } public long DocCount { get; set; } public long? DocCountErrorUpperBound { get; set; } public IReadOnlyCollection Items { get; set; } = EmptyReadOnly.Collection; public IReadOnlyDictionary Meta { get; set; } = EmptyReadOnly.Dictionary; public long? SumOtherDocCount { get; set; } public DateMathTime AutoInterval { get; set; } } }