Skip to content

implement IPercentageScoreHeuristic on PercentageScoreHeuristic #4574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Nest
[ReadAs(typeof(PercentageScoreHeuristic))]
public interface IPercentageScoreHeuristic { }

public class PercentageScoreHeuristic { }
public class PercentageScoreHeuristic : IPercentageScoreHeuristic { }

public class PercentageScoreHeuristicDescriptor
: DescriptorBase<PercentageScoreHeuristicDescriptor, IPercentageScoreHeuristic>, IPercentageScoreHeuristic { }
Expand Down
34 changes: 34 additions & 0 deletions tests/Tests.Reproduce/GitHubIssue4573.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Text;
using Elastic.Xunit.XunitPlumbing;
using FluentAssertions;
using Nest;
using Tests.Core.Client;

namespace Tests.Reproduce
{
public class GitHubIssue4573
{
[U]
public void SerializePercentageScore()
{
Func<ISearchResponse<object>> action = () => TestClient.DefaultInMemoryClient.Search<object>(b => b
.Aggregations(a => a
.SignificantTerms("related_organisations", sigTerms => sigTerms
.Field("organisations.keyword")
.Size(10)
.PercentageScore(p => p)
.MinimumDocumentCount(5)
)
)
);

action.Should().NotThrow();

var response = action();

var json = Encoding.UTF8.GetString(response.ApiCall.RequestBodyInBytes);
json.Should().Contain("\"percentage\":{}");
}
}
}