|
| 1 | +using System; |
| 2 | +using System.Globalization; |
| 3 | +using System.Text; |
| 4 | +using Elastic.Xunit.XunitPlumbing; |
| 5 | +using Elasticsearch.Net; |
| 6 | +using FluentAssertions; |
| 7 | +using FluentAssertions.Common; |
| 8 | +using Nest; |
| 9 | +using Newtonsoft.Json.Linq; |
| 10 | +using Tests.Core.Client; |
| 11 | +using Tests.Core.Extensions; |
| 12 | +using Tests.Core.Serialization; |
| 13 | +using Tests.Domain; |
| 14 | + |
| 15 | +namespace Tests.Reproduce |
| 16 | +{ |
| 17 | + public class Discuss179634 |
| 18 | + { |
| 19 | + [U] |
| 20 | + public void SerializeCompletionSuggesterFieldsCorrectlyWhenDefaultFieldNameInferrerUsed() |
| 21 | + { |
| 22 | + var connectionPool = new SingleNodeConnectionPool(new Uri("http://localhost:9200")); |
| 23 | + var settings = new ConnectionSettings(connectionPool, new InMemoryConnection()) |
| 24 | + .DefaultFieldNameInferrer(p => p.ToUpper(CultureInfo.CurrentCulture)) |
| 25 | + .DisableDirectStreaming(); |
| 26 | + |
| 27 | + var tester = new SerializationTester(new ElasticClient(settings)); |
| 28 | + |
| 29 | + var suggest = new SearchDescriptor<Project>() |
| 30 | + .Suggest(ss => ss |
| 31 | + .Completion("title", cs => cs |
| 32 | + .Field(f => f.Suggest) |
| 33 | + .Prefix("keyword") |
| 34 | + .Fuzzy(f => f |
| 35 | + .Fuzziness(Fuzziness.Auto) |
| 36 | + ) |
| 37 | + .Size(5) |
| 38 | + ) |
| 39 | + ); |
| 40 | + |
| 41 | + var expected = @"{ |
| 42 | + ""suggest"": { |
| 43 | + ""title"": { |
| 44 | + ""completion"": { |
| 45 | + ""field"": ""SUGGEST"", |
| 46 | + ""size"": 5, |
| 47 | + ""fuzzy"": { |
| 48 | + ""fuzziness"": ""AUTO"" |
| 49 | + } |
| 50 | + }, |
| 51 | + ""prefix"": ""keyword"" |
| 52 | + } |
| 53 | + } |
| 54 | +}"; |
| 55 | + |
| 56 | + var result = tester.Serializes(suggest, expected); |
| 57 | + result.Success.Should().Be(true, result.DiffFromExpected); |
| 58 | + } |
| 59 | + } |
| 60 | +} |
0 commit comments