From 3f53763f6e376ea8dab7183d54d6243c5fe0c96c Mon Sep 17 00:00:00 2001 From: Mpdreamz Date: Mon, 14 Mar 2016 15:18:28 +0100 Subject: [PATCH] added reproduce test to showcase #1906 --- .editorconfig | 20 +++------ .../ApiEndpoints/get.json | 2 +- .../Domain/CsharpMethod.cs | 2 +- .../IElasticLowLevelClient.cs | 3 +- src/Tests/Reproduce/GithubIssue1906.cs | 42 +++++++++++++++++++ 5 files changed, 51 insertions(+), 18 deletions(-) create mode 100644 src/Tests/Reproduce/GithubIssue1906.cs diff --git a/.editorconfig b/.editorconfig index 6010bc555be..ed8eb370407 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,5 +1,9 @@ root=true +[*.cs] +trim_trailing_whitespace=true +insert_final_newline=true + [*] indent_style = tab indent_size = 4 @@ -8,22 +12,10 @@ indent_size = 4 indent_style = tab indent_size = 4 -[*.js] -indent_style = space -indent_size = 2 - -[*.fs] -indent_style = space -indent_size = 4 - -[*.fsx] +[*.{fs,fsx}] indent_style = space indent_size = 4 -[*.markdown] -indent_style = space -indent_size = 2 - -[*.json] +[*.{md,markdown,json,js}] indent_style = space indent_size = 2 diff --git a/src/CodeGeneration/CodeGeneration.LowLevelClient/ApiEndpoints/get.json b/src/CodeGeneration/CodeGeneration.LowLevelClient/ApiEndpoints/get.json index f2212d3a44a..0cc21e0c1d5 100644 --- a/src/CodeGeneration/CodeGeneration.LowLevelClient/ApiEndpoints/get.json +++ b/src/CodeGeneration/CodeGeneration.LowLevelClient/ApiEndpoints/get.json @@ -72,4 +72,4 @@ }, "body": null } -} +} \ No newline at end of file diff --git a/src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/CsharpMethod.cs b/src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/CsharpMethod.cs index 9691e5c882c..2a066e44a25 100644 --- a/src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/CsharpMethod.cs +++ b/src/CodeGeneration/CodeGeneration.LowLevelClient/Domain/CsharpMethod.cs @@ -283,4 +283,4 @@ public IEnumerable GetFluentRouteSetters() public bool IsDocumentPath => AllParts.Count() == 3 && AllParts.All(p => p.Type != "list") && AllParts.All(p => new[] { "index", "type", "id" }.Contains(p.Name)); public IEnumerable AllParts => (this.Url?.Parts?.Values ?? Enumerable.Empty()).Where(p => !string.IsNullOrWhiteSpace(p.Name)); } -} \ No newline at end of file +} diff --git a/src/Elasticsearch.Net/IElasticLowLevelClient.cs b/src/Elasticsearch.Net/IElasticLowLevelClient.cs index dc9813f105c..9d25a007dbb 100644 --- a/src/Elasticsearch.Net/IElasticLowLevelClient.cs +++ b/src/Elasticsearch.Net/IElasticLowLevelClient.cs @@ -3,7 +3,7 @@ namespace Elasticsearch.Net { public partial interface IElasticLowLevelClient - { + { /// /// Perform any request you want over the configured IConnection synchronously while taking advantage of the cluster failover. /// @@ -27,6 +27,5 @@ ElasticsearchResponse DoRequest(HttpMethod method, string path, PostDataA task of ElasticsearchResponse of T where T represents the JSON response body Task> DoRequestAsync(HttpMethod method, string path, PostData data = null, IRequestParameters requestParameters = null) where T : class; - } } diff --git a/src/Tests/Reproduce/GithubIssue1906.cs b/src/Tests/Reproduce/GithubIssue1906.cs new file mode 100644 index 00000000000..89f5cbca06d --- /dev/null +++ b/src/Tests/Reproduce/GithubIssue1906.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Elasticsearch.Net; +using Nest; +using FluentAssertions; +using Tests.Framework; + +namespace Tests.Reproduce +{ + public class GithubIssue1906 + { + private class ESLogEvent { } + + [U] public void SearchDoesNotTakeDefaultIndexIntoAccount() + { + var node = new Uri("http://localhost:9200"); + var connectionPool = new SingleNodeConnectionPool(node); + var connectionSettings = new ConnectionSettings(connectionPool, connection: new InMemoryConnection()) + .DefaultIndex("logstash-*") + .DefaultFieldNameInferrer(p => p) + .OnRequestCompleted(info => + { + // info.Uri is /_search/ without the default index + // my ES instance throws an error on the .kibana index (@timestamp field not mapped because I sort on @timestamp) + }); + + var client = new ElasticClient(connectionSettings); + var response = client.Search(s=>s); + + response.ApiCall.Uri.AbsolutePath.Should().Be("/logstash-%2A/eslogevent/_search"); + + response = client.Search(new SearchRequest{ }); + response.ApiCall.Uri.AbsolutePath.Should().Be("/logstash-%2A/eslogevent/_search"); + + response = client.Search(new SearchRequest { }); + response.ApiCall.Uri.AbsolutePath.Should().Be("/_search"); + + } + } +}