Skip to content

Commit 68e81b4

Browse files
committed
removed all raw calls on IElasticClient as we now have IRawElasticClient for this purpose.
- exposed bits on IElasticClient so you can easily parse the string response of IRawElasticClient - exposed IConnection as a property on IElasticClient
1 parent d5c66c6 commit 68e81b4

21 files changed

+99
-150
lines changed

src/Nest.Dsl.Factory/ElasticClient-Search.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,19 @@ namespace Nest
99
{
1010
public static class ElasticClientExtensions
1111
{
12+
public static IQueryResponse<T> SearchRaw<T>(this IElasticClient client,
13+
string path, string query) where T : class
14+
{
15+
var connectionStatus = client.Connection.PostSync(path, query);
16+
return client.ToParsedResponse<QueryResponse<T>>(connectionStatus);
17+
}
1218

19+
public static Task<IQueryResponse<T>> SearchRawAsync<T>(this IElasticClient client,
20+
string path, string query) where T : class
21+
{
22+
return client.Connection.Post(path, query)
23+
.ContinueWith(t=> client.ToParsedResponse<QueryResponse<T>>(t.Result) as IQueryResponse<T>);
24+
}
1325
/// <summary>
1426
/// Synchronously search using dynamic as its return type.
1527
/// </summary>

src/Nest.Tests.Integration/Core/DeleteTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void GetDocumentById()
3838
{
3939
//arrange
4040
//pull existing example through method we know is functional based on other passing unit tests
41-
var queryResults = this._client.SearchRaw<ElasticSearchProject>(
41+
var queryResults = this.SearchRaw<ElasticSearchProject>(
4242
@" { ""query"" : {
4343
""fuzzy"" : {
4444
""followers.firstName"" : """ + NestTestData.Data.First().Followers.First().FirstName.ToLower() + @"x""

src/Nest.Tests.Integration/Facet/GeoDistanceFacetResponseTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class GeoDistanceFacetResponseTests : BaseFacetTestFixture
1010
[Test]
1111
public void SimpleGeoFacet()
1212
{
13-
var queryResults = this._client.SearchRaw<ElasticSearchProject>(
13+
var queryResults = this.SearchRaw<ElasticSearchProject>(
1414
@"
1515
{
1616
""query"" : { ""match_all"" : { } },

src/Nest.Tests.Integration/Facet/HistogramFacetResponseTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class HistogramFacetResponseTests : BaseFacetTestFixture
1414
[Test]
1515
public void SimpleHistogramFacet()
1616
{
17-
var queryResults = this._client.SearchRaw<ElasticSearchProject>(
17+
var queryResults = this.SearchRaw<ElasticSearchProject>(
1818
@"
1919
{
2020
""query"" : { ""match_all"" : { } },
@@ -50,7 +50,7 @@ public void SimpleHistogramFacet()
5050
[Test]
5151
public void DateHistogramFacet()
5252
{
53-
var queryResults = this._client.SearchRaw<ElasticSearchProject>(
53+
var queryResults = this.SearchRaw<ElasticSearchProject>(
5454
@"
5555
{
5656
""query"" : { ""match_all"" : { } },

src/Nest.Tests.Integration/Facet/RangeFacetResponseTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class RangeFacetResponseTests : BaseFacetTestFixture
1414
[Test]
1515
public void SimpleRangeFacet()
1616
{
17-
var queryResults = this._client.SearchRaw<ElasticSearchProject>(
17+
var queryResults = this.SearchRaw<ElasticSearchProject>(
1818
@"
1919
{
2020
""query"" : { ""match_all"" : { } },
@@ -54,7 +54,7 @@ public void SimpleRangeFacet()
5454
[Test]
5555
public void DateRangeFacet()
5656
{
57-
var queryResults = this._client.SearchRaw<ElasticSearchProject>(
57+
var queryResults = this.SearchRaw<ElasticSearchProject>(
5858
@"
5959
{
6060
""query"" : { ""match_all"" : { } },

src/Nest.Tests.Integration/Facet/TermFacetResponseTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class TermFacetResponseTests : BaseFacetTestFixture
1313
[Test]
1414
public void SimpleTermFacet()
1515
{
16-
IQueryResponse<ElasticSearchProject> queryResults = this._client.SearchRaw<ElasticSearchProject>(
16+
IQueryResponse<ElasticSearchProject> queryResults = this.SearchRaw<ElasticSearchProject>(
1717
@" { ""query"" : {
1818
""match_all"" : { }
1919
},
@@ -55,7 +55,7 @@ public void SimpleTermFacet()
5555
[Test]
5656
public void SimpleTermFacetWithExclude()
5757
{
58-
IQueryResponse<ElasticSearchProject> queryResults = this._client.SearchRaw<ElasticSearchProject>(
58+
IQueryResponse<ElasticSearchProject> queryResults = this.SearchRaw<ElasticSearchProject>(
5959
@" { ""query"" : {
6060
""match_all"" : { }
6161
},
@@ -82,7 +82,7 @@ public void SimpleTermFacetWithExclude()
8282
[Test]
8383
public void SimpleTermFacetWithGlobal()
8484
{
85-
IQueryResponse<ElasticSearchProject> queryResults = this._client.SearchRaw<ElasticSearchProject>(
85+
IQueryResponse<ElasticSearchProject> queryResults = this.SearchRaw<ElasticSearchProject>(
8686
@" { ""query"" : {
8787
""term"" : { ""followers.lastName"" : """ + this._LookFor.ToLower() +
8888
@""" }

src/Nest.Tests.Integration/Facet/TermStatsFacetResponseTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class TermStatsFacetResponseTests : BaseFacetTestFixture
1212
[Test]
1313
public void SimpleTermStatsFacet()
1414
{
15-
var queryResults = this._client.SearchRaw<ElasticSearchProject>(
15+
var queryResults = this.SearchRaw<ElasticSearchProject>(
1616
@"
1717
{
1818
""query"" : { ""match_all"" : { } },

src/Nest.Tests.Integration/Indices/OpenCloseTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void CloseAndSearchAndOpenIndex()
3737
Assert.True(r.OK);
3838
Assert.True(r.Acknowledged);
3939
Assert.True(r.IsValid);
40-
var results = this._client.SearchRaw<ElasticSearchProject>(
40+
var results = this.SearchRaw<ElasticSearchProject>(
4141
@" { ""query"" : {
4242
""match_all"" : { }
4343
} }"

src/Nest.Tests.Integration/IntegrationTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ protected string GetTypeNameFor(Type t)
3030
return new TypeNameResolver().GetTypeNameFor(t).Resolve(this._settings);
3131
}
3232

33+
34+
protected IQueryResponse<T> SearchRaw<T>(string query) where T : class
35+
{
36+
var index = this._client.GetIndexNameFor<T>();
37+
var typeName = this._client.GetTypeNameFor<T>();
38+
var connectionStatus = this._client.Raw.SearchPost(index, typeName, query);
39+
return this._client.ToParsedResponse<QueryResponse<T>>(connectionStatus);
40+
}
41+
3342
public void DoFilterTest(Func<FilterDescriptor<ElasticSearchProject>, Nest.BaseFilter> filter, ElasticSearchProject project, bool queryMustHaveResults)
3443
{
3544
var filterId = Filter<ElasticSearchProject>.Term(e => e.Id, project.Id.ToString());

src/Nest.Tests.Integration/Search/ExplainTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class ExplainTests : IntegrationTests
1313
[Test]
1414
public void SimpleExplain()
1515
{
16-
var queryResults = this._client.SearchRaw<ElasticSearchProject>(
16+
var queryResults = this.SearchRaw<ElasticSearchProject>(
1717
@" {
1818
""explain"": true,
1919
""query"" : {
@@ -27,7 +27,7 @@ public void SimpleExplain()
2727
[Test]
2828
public void ComplexExplain()
2929
{
30-
var queryResults = this._client.SearchRaw<ElasticSearchProject>(
30+
var queryResults = this.SearchRaw<ElasticSearchProject>(
3131
@" { ""explain"": true,
3232
""query"" : {
3333
""fuzzy"" : {

0 commit comments

Comments
 (0)