I created an AggregationsHelper
object and I called .Filter
method on it
var aggr = new AggregationsHelper();
aggr .Filter("test");
I get a null exception when calling the .Filter
function. Do I have to initiate the object somehow?
EDIT:
As pointed out by @Val, I have to pass a dictionary to the object via the constructor
My real question is how to mock such complex ElasticSearch aggregation query:
var res = ElasticClient.Search<DataRecord>(s => s
.SearchType(SearchType.Count)
.Aggregations(a => a.Filter(
"histIdFilter",
f => f.Filter(
f2 => f2.Term(
t => t.HistoryId,
groupId))
.Aggregations(ag => ag.Filter("timeRangeFilter", fg => fg.Filter(fg2 => fg2.Range(i => i.OnField(b => b.DateTime))))))));
// Applying filter
var ah = res.Aggs;
var histIdAgg = ah.Filter("histIdFilter");
var timeRangeAgg = histIdAgg.Filter("timeRangeFilter");
I successfully managed to mock the .Aggr
property of the query response, using
datResp.SetupGet(x => x.Aggs).Returns(ah.Object);
but when I call .Filter
on the ah
object I get a null exception like if the internal dictionary was not set for some reason
Aucun commentaire:
Enregistrer un commentaire