diff --git a/src/Nest/Search/Suggesters/SuggestBucket.cs b/src/Nest/Search/Suggesters/SuggestBucket.cs index bdf6870e3bd..602028c2a44 100644 --- a/src/Nest/Search/Suggesters/SuggestBucket.cs +++ b/src/Nest/Search/Suggesters/SuggestBucket.cs @@ -28,15 +28,22 @@ public interface ISuggestBucket public class SuggestBucket : ISuggestBucket { + [DataMember(Name = "completion")] public ICompletionSuggester Completion { get; set; } + [DataMember(Name = "phrase")] public IPhraseSuggester Phrase { get; set; } + [DataMember(Name = "prefix")] public string Prefix { get; set; } + [DataMember(Name = "regex")] public string Regex { get; set; } + [DataMember(Name = "term")] public ITermSuggester Term { get; set; } + + [DataMember(Name = "text")] public string Text { get; set; } } } diff --git a/src/Tests/Tests.Reproduce/Discuss179634.cs b/src/Tests/Tests.Reproduce/Discuss179634.cs new file mode 100644 index 00000000000..0a166b9096a --- /dev/null +++ b/src/Tests/Tests.Reproduce/Discuss179634.cs @@ -0,0 +1,47 @@ +using System; +using System.Globalization; +using System.Text; +using Elastic.Xunit.XunitPlumbing; +using Elasticsearch.Net; +using FluentAssertions; +using FluentAssertions.Common; +using Nest; +using Newtonsoft.Json.Linq; +using Tests.Core.Client; +using Tests.Core.Extensions; +using Tests.Core.Serialization; +using Tests.Domain; + +namespace Tests.Reproduce +{ + public class Discuss179634 + { + [U] + public void SerializeCompletionSuggesterFieldsCorrectlyWhenDefaultFieldNameInferrerUsed() + { + var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200")); + var settings = new ConnectionSettings(connectionPool, new InMemoryConnection()) + .DefaultFieldNameInferrer(p => p.ToUpper(CultureInfo.CurrentCulture)) + .DisableDirectStreaming(); + + var tester = new SerializationTester(new ElasticClient(settings)); + + var suggest = new SearchDescriptor() + .Suggest(ss => ss + .Completion("title", cs => cs + .Field(f => f.Suggest) + .Prefix("keyword") + .Fuzzy(f => f + .Fuzziness(Fuzziness.Auto) + ) + .Size(5) + ) + ); + + var expected = @"{""suggest"":{""title"":{""completion"":{""fuzzy"":{""fuzziness"":""AUTO""},""field"":""SUGGEST"",""size"":5},""prefix"":""keyword""}}}"; + + var result = tester.Serializes(suggest, expected); + result.Success.Should().Be(true, result.DiffFromExpected); + } + } +}