|
| 1 | +using FluentAssertions; |
| 2 | +using Nest.Tests.MockData.Domain; |
| 3 | +using NUnit.Framework; |
| 4 | +using System; |
| 5 | +using System.Collections.Generic; |
| 6 | +using System.Linq; |
| 7 | +using System.Text; |
| 8 | +using System.Threading.Tasks; |
| 9 | + |
| 10 | +namespace Nest.Tests.Integration.Reproduce |
| 11 | +{ |
| 12 | + [TestFixture] |
| 13 | + public class Reproduce1169Tests : IntegrationTests |
| 14 | + { |
| 15 | + [Test] |
| 16 | + public void TopHitsReturnedFirst() |
| 17 | + { |
| 18 | + var response = this.Client.Search<ElasticsearchProject>(s => s |
| 19 | + .Size(0) |
| 20 | + .Aggregations(a => a |
| 21 | + .TopHits("my-top-hits", th => th |
| 22 | + .Size(1) |
| 23 | + ) |
| 24 | + .Terms("a", t => t |
| 25 | + .Field(p => p.Name) |
| 26 | + ) |
| 27 | + ) |
| 28 | + ); |
| 29 | + |
| 30 | + response.IsValid.Should().BeTrue(); |
| 31 | + |
| 32 | + var topHits = response.Aggs.TopHitsMetric("my-top-hits"); |
| 33 | + topHits.Should().NotBeNull(); |
| 34 | + topHits.Hits<ElasticsearchProject>().Count().Should().BeGreaterThan(0); |
| 35 | + |
| 36 | + var terms = response.Aggs.Terms("a"); |
| 37 | + terms.Should().NotBeNull(); |
| 38 | + terms.Items.Count().Should().BeGreaterThan(0); |
| 39 | + } |
| 40 | + |
| 41 | + [Test] |
| 42 | + public void TermsReturnedFirst() |
| 43 | + { |
| 44 | + var response = this.Client.Search<ElasticsearchProject>(s => s |
| 45 | + .Size(0) |
| 46 | + .Aggregations(a => a |
| 47 | + .TopHits("my-top-hits", th => th |
| 48 | + .Size(1) |
| 49 | + ) |
| 50 | + .Terms("b", t => t |
| 51 | + .Field(p => p.Name) |
| 52 | + ) |
| 53 | + ) |
| 54 | + ); |
| 55 | + |
| 56 | + response.IsValid.Should().BeTrue(); |
| 57 | + |
| 58 | + var topHits = response.Aggs.TopHitsMetric("my-top-hits"); |
| 59 | + topHits.Should().NotBeNull(); |
| 60 | + topHits.Hits<ElasticsearchProject>().Count().Should().BeGreaterThan(0); |
| 61 | + |
| 62 | + var terms = response.Aggs.Terms("b"); |
| 63 | + terms.Should().NotBeNull(); |
| 64 | + terms.Items.Count().Should().BeGreaterThan(0); |
| 65 | + } |
| 66 | + } |
| 67 | +} |
0 commit comments