Initial commit

This commit is contained in:
2022-07-06 21:35:05 +02:00
commit b2494052ff
97220 changed files with 2449256 additions and 0 deletions
@@ -0,0 +1,36 @@
using System.Collections.Generic;
using Gos.Core.Search.Aggregations;
using Gos.Core.Search.Queries;
using Gos.ServiceModel.Enums;
using Gos.ServiceModel.Types;
namespace Gos.Services.Search.Aggregations
{
public abstract class BaseAggregationProvider : IAggregationProvider
{
private readonly IAggregatorFactory aggregatorFactory;
protected BaseAggregationProvider(IAggregatorFactory aggregatorFactory)
{
this.aggregatorFactory = aggregatorFactory;
}
public abstract AggregationType Type { get; }
public Aggregation Get<TQuery>(TQuery query)
where TQuery : Query
{
// Run aggregator
var aggregator = aggregatorFactory.GetAggregator(Type);
var items = aggregator.Get(query);
return new Aggregation()
{
Items = GetItems(items),
Type = Type,
};
}
protected abstract List<AggregationItem> GetItems(IDictionary<string, int> items);
}
}