-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attribute SuggestBucket for serialization #3763
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Project>() | ||
.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); | ||
} | ||
} | ||
} |