Skip to content

Commit

Permalink
added reproduce test to showcase #1906
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz committed Mar 14, 2016
1 parent 7208634 commit 3f53763
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 18 deletions.
20 changes: 6 additions & 14 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
root=true

[*.cs]
trim_trailing_whitespace=true
insert_final_newline=true

[*]
indent_style = tab
indent_size = 4
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@
},
"body": null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,4 @@ public IEnumerable<FluentRouteSetter> 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<ApiUrlPart> AllParts => (this.Url?.Parts?.Values ?? Enumerable.Empty<ApiUrlPart>()).Where(p => !string.IsNullOrWhiteSpace(p.Name));
}
}
}
3 changes: 1 addition & 2 deletions src/Elasticsearch.Net/IElasticLowLevelClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Elasticsearch.Net
{
public partial interface IElasticLowLevelClient
{
{
/// <summary>
/// Perform any request you want over the configured IConnection synchronously while taking advantage of the cluster failover.
/// </summary>
Expand All @@ -27,6 +27,5 @@ ElasticsearchResponse<T> DoRequest<T>(HttpMethod method, string path, PostData<o
/// <returns>A task of ElasticsearchResponse of T where T represents the JSON response body</returns>
Task<ElasticsearchResponse<T>> DoRequestAsync<T>(HttpMethod method, string path, PostData<object> data = null, IRequestParameters requestParameters = null)
where T : class;

}
}
42 changes: 42 additions & 0 deletions src/Tests/Reproduce/GithubIssue1906.cs
Original file line number Diff line number Diff line change
@@ -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<ESLogEvent>(s=>s);

response.ApiCall.Uri.AbsolutePath.Should().Be("/logstash-%2A/eslogevent/_search");

response = client.Search<ESLogEvent>(new SearchRequest<ESLogEvent>{ });
response.ApiCall.Uri.AbsolutePath.Should().Be("/logstash-%2A/eslogevent/_search");

response = client.Search<ESLogEvent>(new SearchRequest { });
response.ApiCall.Uri.AbsolutePath.Should().Be("/_search");

}
}
}

0 comments on commit 3f53763

Please sign in to comment.