Skip to content

Commit

Permalink
Updating to Elasticsearch 2.3.1 SearchType count removed
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbod committed May 18, 2016
1 parent 1dd8395 commit 0f301ca
Show file tree
Hide file tree
Showing 14 changed files with 2,594 additions and 2,528 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace ElasticsearchCRUD.Integration.Test.AggregationTests
{
public class GeohashGridBucketAggregationTests : SetupSearchAgg, IDisposable
{
{
public GeohashGridBucketAggregationTests()
{
Setup();
Expand All @@ -21,104 +21,108 @@ public void Dispose()
}

[Fact]
public void SearchAggGeohashGridBucketAggregationWithNoHits()
{
var search = new Search
{
Aggs = new List<IAggs>
{
new GeohashGridBucketAggregation("testGeohashGridBucketAggregation", "location")
}
};
public void SearchAggGeohashGridBucketAggregationWithNoHits()
{
var search = new Search
{
Size = 0,
Aggs = new List<IAggs>
{
new GeohashGridBucketAggregation("testGeohashGridBucketAggregation", "location")
}
};

using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
{
Assert.True(context.IndexTypeExists<SearchAggTest>());
var items = context.Search<SearchAggTest>(search, new SearchUrlParameters { SeachType = SeachType.count });
var aggResult = items.PayloadResult.Aggregations.GetComplexValue<GeohashGridBucketAggregationsResult>("testGeohashGridBucketAggregation");
Assert.Equal(3, aggResult.Buckets[0].DocCount);
}
}
using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
{
Assert.True(context.IndexTypeExists<SearchAggTest>());
var items = context.Search<SearchAggTest>(search);
var aggResult = items.PayloadResult.Aggregations.GetComplexValue<GeohashGridBucketAggregationsResult>("testGeohashGridBucketAggregation");
Assert.Equal(3, aggResult.Buckets[0].DocCount);
}
}

[Fact]
public void SearchAggGeohashGridBucketAggregationWithTopHitsSubWithNoHits()
{
var search = new Search
{
Aggs = new List<IAggs>
{
new GeohashGridBucketAggregation("testGeohashGridBucketAggregation", "location")
{
Aggs = new List<IAggs>
{
new TopHitsMetricAggregation("tophits")
}
}
}
};
[Fact]
public void SearchAggGeohashGridBucketAggregationWithTopHitsSubWithNoHits()
{
var search = new Search
{
Size = 0,
Aggs = new List<IAggs>
{
new GeohashGridBucketAggregation("testGeohashGridBucketAggregation", "location")
{
Aggs = new List<IAggs>
{
new TopHitsMetricAggregation("tophits")
}
}
}
};

using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
{
Assert.True(context.IndexTypeExists<SearchAggTest>());
var items = context.Search<SearchAggTest>(search, new SearchUrlParameters { SeachType = SeachType.count });
var aggResult = items.PayloadResult.Aggregations.GetComplexValue<GeohashGridBucketAggregationsResult>("testGeohashGridBucketAggregation");
var topHits = aggResult.Buckets[0].GetSubAggregationsFromJTokenName<TopHitsMetricAggregationsResult<SearchAggTest>>("tophits");
Assert.Equal(3, aggResult.Buckets[0].DocCount);
Assert.Equal(3, topHits.Hits.Total);
}
}
using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
{
Assert.True(context.IndexTypeExists<SearchAggTest>());
var items = context.Search<SearchAggTest>(search);
var aggResult = items.PayloadResult.Aggregations.GetComplexValue<GeohashGridBucketAggregationsResult>("testGeohashGridBucketAggregation");
var topHits = aggResult.Buckets[0].GetSubAggregationsFromJTokenName<TopHitsMetricAggregationsResult<SearchAggTest>>("tophits");
Assert.Equal(3, aggResult.Buckets[0].DocCount);
Assert.Equal(3, topHits.Hits.Total);
}
}

[Fact]
public void SearchAggGeohashGridBucketAggregationPrecisionWithNoHits()
{
var search = new Search
{
Aggs = new List<IAggs>
{
new GeohashGridBucketAggregation("testGeohashGridBucketAggregation", "location")
{
Precision = 7,
Size = 100,
ShardSize= 200
}
}
};
[Fact]
public void SearchAggGeohashGridBucketAggregationPrecisionWithNoHits()
{
var search = new Search
{
Size = 0,
Aggs = new List<IAggs>
{
new GeohashGridBucketAggregation("testGeohashGridBucketAggregation", "location")
{
Precision = 7,
Size = 100,
ShardSize= 200
}
}
};

using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
{
Assert.True(context.IndexTypeExists<SearchAggTest>());
var items = context.Search<SearchAggTest>(search, new SearchUrlParameters { SeachType = SeachType.count });
var aggResult = items.PayloadResult.Aggregations.GetComplexValue<GeohashGridBucketAggregationsResult>("testGeohashGridBucketAggregation");
Assert.Equal(3, aggResult.Buckets[0].DocCount);
}
}
using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
{
Assert.True(context.IndexTypeExists<SearchAggTest>());
var items = context.Search<SearchAggTest>(search);
var aggResult = items.PayloadResult.Aggregations.GetComplexValue<GeohashGridBucketAggregationsResult>("testGeohashGridBucketAggregation");
Assert.Equal(3, aggResult.Buckets[0].DocCount);
}
}

[Fact]
public void SearchAggTermsBucketAggregationScriptWithNoHits()
{
var search = new Search
{
Aggs = new List<IAggs>
{
new GeohashGridBucketAggregation("testGeohashGridBucketAggregation", "location")
{
Script = "_value * times * constant",
Params = new List<ScriptParameter>
{
new ScriptParameter("times", 1.4),
new ScriptParameter("constant", 10.2)
}
}
}
};
[Fact]
public void SearchAggTermsBucketAggregationScriptWithNoHits()
{
var search = new Search
{
Size = 0,
Aggs = new List<IAggs>
{
new GeohashGridBucketAggregation("testGeohashGridBucketAggregation", "location")
{
Script = "_value * times * constant",
Params = new List<ScriptParameter>
{
new ScriptParameter("times", 1.4),
new ScriptParameter("constant", 10.2)
}
}
}
};

using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
{
Assert.True(context.IndexTypeExists<SearchAggTest>());
var items = context.Search<SearchAggTest>(search, new SearchUrlParameters { SeachType = SeachType.count });
var aggResult = items.PayloadResult.Aggregations.GetComplexValue<GeohashGridBucketAggregationsResult>("testGeohashGridBucketAggregation");
Assert.Equal(3, aggResult.Buckets[0].DocCount);
}
}
using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
{
Assert.True(context.IndexTypeExists<SearchAggTest>());
var items = context.Search<SearchAggTest>(search);
var aggResult = items.PayloadResult.Aggregations.GetComplexValue<GeohashGridBucketAggregationsResult>("testGeohashGridBucketAggregation");
Assert.Equal(3, aggResult.Buckets[0].DocCount);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,61 +22,64 @@ public void Dispose()
}

[Fact]
public void SearchAggGlobalBucketAggregationWithNoHits()
{
var search = new Search
{
Aggs = new List<IAggs>
{
new GlobalBucketAggregation("globalbucket")
}
};
public void SearchAggGlobalBucketAggregationWithNoHits()
{
var search = new Search
{
Size = 0,
Aggs = new List<IAggs>
{
new GlobalBucketAggregation("globalbucket")
}
};

using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
{
Assert.True(context.IndexTypeExists<SearchAggTest>());
var items = context.Search<SearchAggTest>(search, new SearchUrlParameters { SeachType = SeachType.count });
var aggResult = items.PayloadResult.Aggregations.GetComplexValue<GlobalBucketAggregationsResult>("globalbucket");
Assert.Equal(7, aggResult.DocCount);
}
}
using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
{
Assert.True(context.IndexTypeExists<SearchAggTest>());
var items = context.Search<SearchAggTest>(search);
var aggResult = items.PayloadResult.Aggregations.GetComplexValue<GlobalBucketAggregationsResult>("globalbucket");
Assert.Equal(7, aggResult.DocCount);
}
}

[Fact]
public void SearchAggGlobalBucketAggregationWithChildrenNoHits()
{
var search = new Search
{
Aggs = new List<IAggs>
{
new GlobalBucketAggregation("globalbucket")
{
Aggs = new List<IAggs>
{
new MaxMetricAggregation("maxAgg", "lift"),
new MinMetricAggregation("minAgg", "lift"),
}
}
}
};
[Fact]
public void SearchAggGlobalBucketAggregationWithChildrenNoHits()
{
var search = new Search
{
Size = 0,
Aggs = new List<IAggs>
{
new GlobalBucketAggregation("globalbucket")
{
Aggs = new List<IAggs>
{
new MaxMetricAggregation("maxAgg", "lift"),
new MinMetricAggregation("minAgg", "lift"),
}
}
}
};

using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
{
Assert.True(context.IndexTypeExists<SearchAggTest>());
var items = context.Search<SearchAggTest>(search, new SearchUrlParameters { SeachType = SeachType.count });
var aggResult = items.PayloadResult.Aggregations.GetComplexValue<GlobalBucketAggregationsResult>("globalbucket");
var max = aggResult.GetSingleMetricSubAggregationValue<double>("maxAgg");
Assert.Equal(7, aggResult.DocCount);
Assert.Equal(2.9, max);
}
}
using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
{
Assert.True(context.IndexTypeExists<SearchAggTest>());
var items = context.Search<SearchAggTest>(search);
var aggResult = items.PayloadResult.Aggregations.GetComplexValue<GlobalBucketAggregationsResult>("globalbucket");
var max = aggResult.GetSingleMetricSubAggregationValue<double>("maxAgg");
Assert.Equal(7, aggResult.DocCount);
Assert.Equal(2.9, max);
}
}

[Fact]
public void SearchAggTermsBucketAggregationWithOrderSumSubSumAggNoHits()
{
[Fact]
public void SearchAggTermsBucketAggregationWithOrderSumSubSumAggNoHits()
{
var ex = Assert.Throws<ElasticsearchCrudException>(() =>
{
var search = new Search
{
Size = 0,
Aggs = new List<IAggs>
{
new TermsBucketAggregation("test_min", "lift")
Expand All @@ -95,7 +98,7 @@ public void SearchAggTermsBucketAggregationWithOrderSumSubSumAggNoHits()
using (var context = new ElasticsearchContext(ConnectionString, ElasticsearchMappingResolver))
{
Assert.True(context.IndexTypeExists<SearchAggTest>());
var items = context.Search<SearchAggTest>(search, new SearchUrlParameters { SeachType = SeachType.count });
var items = context.Search<SearchAggTest>(search);
var aggResult = items.PayloadResult.Aggregations.GetComplexValue<TermsBucketAggregationsResult>("test_min");
var bucketchildAggSum = aggResult.Buckets[0].GetSingleMetricSubAggregationValue<double>("childAggSum");
var bucketchildAggAvg = aggResult.Buckets[0].GetSingleMetricSubAggregationValue<double>("childAggAvg");
Expand All @@ -109,6 +112,6 @@ public void SearchAggTermsBucketAggregationWithOrderSumSubSumAggNoHits()
Assert.Equal("GlobalBucketAggregation cannot be sub aggregations", ex.Message);


}
}
}
}
Loading

0 comments on commit 0f301ca

Please sign in to comment.