Skip to content

Commit 8f85251

Browse files
committed
Merge branch 'develop' of github.com:elasticsearch/elasticsearch-net into develop
2 parents c070d84 + 43ac721 commit 8f85251

File tree

15 files changed

+97
-45
lines changed

15 files changed

+97
-45
lines changed

new_docs/contents/.DS_Store

-6 KB
Binary file not shown.

new_docs/contents/breaking-changes.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
---
22
template: layout.jade
3-
title: Breaking changes
3+
title: Breaking Changes
44
menusection: concepts
55
menuitem: breaking-changes
66
---
77

8-
#Breaking changes
8+
#Breaking Changes
99

1010
## Elasticsearch 1.0
1111

1212
Elasticsearch 1.0 comes with it's own set of breaking changes which [are all documented in the elasticsearch documentation](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.x/breaking-changes.html). This page describes breaking changes NEST introduces in its 1.0 release and to an extend how you should handle Elasticsearch 1.0 changes in your exisiting code base using NEST prior to NEST 1.0.
1313

1414
## NEST 1.0
1515

16-
### Strong named packages
16+
### Strong Named Packages
1717

1818
Prior to 1.0 NEST came with a `NEST` and `NEST.Signed` nuget package. In 1.0 there is one package called `NEST` which is a signed strong named assembly. We follow the example of JSON.NET and only change our `AssemblyVersion` on major releases only update the `AssemblyFileVersion` for every release. This way you get most of the benefits of unsigned assemblies while still providing support for developers who's business guidelines mandates the usage of signed assemblies.
1919

@@ -38,7 +38,7 @@ to `PutMappingDescriptor<T>`
3838

3939
IResponse.Error.Exception no longer exists, it is inlined to IResponse.OriginalException. The Error property did not hold any information that was not available on IResponse.ConnectionStatus.
4040

41-
### Response shortcuts
41+
### Response Shortcuts
4242

4343
Prior to 1.0 some calls directly returned a bool or value instead of the full envelopped Elasticsearch response.
4444

@@ -63,7 +63,7 @@ Or in a separate put mapping call:
6363

6464
var response = this._client.Map<ElasticsearchProject>(m=>m.MapFromAttributes()......);
6565

66-
#### Alias helpers
66+
#### Alias Helpers
6767

6868
NEST 0.12.0 had some alias helpers, `SwapAlias()`, `GetIndicesPointingToAlias()` these have been removed in favor of just `Alias()` and `GetAliases()`. Especially the later could benefit from some extension methods that make the common use cases a bit easier to program with. These did not make the beta release.
6969

new_docs/contents/elasticsearch-net/building-requests.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ menuitem: esnet-building-requests
99

1010
This section decribes how to build requests to Elasticsearch.
1111

12-
## Calling an API endpoint
12+
## Calling an API Endpoint
1313

1414
`Elasticsearch.Net` maps **all** the `Elasticsearch` API endpoints to methods. The reason it can do this is because all these methods are generated from
1515
[the official client rest specification](https://github.com/elasticsearch/elasticsearch/tree/master/rest-api-spec/api). This specification documents all
@@ -32,7 +32,7 @@ Unknown querystring parameters can still be added:
3232

3333
The querystring parameter is always optional.
3434

35-
## Providing request body
35+
## Providing Request Body
3636

3737
Some endpoints need a request body this can be passed in a couple of ways.
3838

new_docs/contents/elasticsearch-net/errors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
template: layout.jade
3-
title: Quick Start
3+
title: Errors
44
menusection:
55
menuitem: esnet-errors
66
---

new_docs/contents/elasticsearch-net/handling-responses.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
template: layout.jade
3-
title: Handling responses
3+
title: Handling Responses
44
menusection:
55
menuitem: esnet-handling-responses
66
---
77

8-
# Handling responses
8+
# Handling Responses
99

1010
Describes how to handle the the response objects from `Elasticsearch.Net`
1111

@@ -34,7 +34,7 @@ A `byte[]` representation of the response from elasticsearch, only set when `Exp
3434
#### Response
3535
The deserialized `T` object representing the response.
3636

37-
## Typed API calls
37+
## Typed API Calls
3838

3939
`Elasticsearch.Net` does not provide typed objects representing the responses this is up to the developer to map.
4040

new_docs/contents/nest/handling-responses.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
22
template: layout.jade
3-
title: Connecting
3+
title: Handling Responses
44
menusection: concepts
55
menuitem: handling-responses
66
---
77

88

9-
# Handling responses
9+
# Handling Responses
1010

1111

1212
All the return objects from API calls in NEST client implement:

new_docs/contents/nest/index-type-inference.markdown

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
template: layout.jade
3-
title: Connecting
3+
title: Type/Index Inference
44
menusection: concepts
55
menuitem: index-type-inference
66
---
@@ -40,11 +40,11 @@ As noted in the [quick start](/nest/quick-start.html) you can always pass **expl
4040
.Ttl("1m")
4141
);
4242

43-
This will index the document using `/another-index/another-type/1-should-not-be-the-id?refresh=true&&ttl=1m` as the url.
43+
This will index the document using `/another-index/another-type/1-should-not-be-the-id?refresh=true&ttl=1m` as the url.
4444

4545
There are a couple of places within NEST where inference comes in to play
4646

47-
## Index name inference
47+
## Index Name Inference
4848

4949
Whenever an explicit index name is not provided NEST will look to see if the type has it's own default index name on the connection settings.
5050

@@ -56,12 +56,12 @@ Whenever an explicit index name is not provided NEST will look to see if the typ
5656
// searches in /my-type-index/mytype/_search
5757
client.Search<MyType>()
5858

59-
// searches in /my-default-index/mytype/_search
59+
// searches in /my-default-index/person/_search
6060
client.Search<Person>()
6161

6262
`MyType` defaults to `my-type-index` because it is explicitly configured but `Person` will default to the global fallback `my-default-index`.
6363

64-
## Type name inference
64+
## Type Name Inference
6565

6666
Whenever NEST needs a type name but is not given one explicitly it will use the given CLR type to infer it's Elasticsearch type name.
6767

@@ -90,7 +90,7 @@ Prior to NEST 1.0 typenames were by default lowercased AND pluralized, if you wa
9090

9191
settings.PluralizeTypeNames();
9292

93-
## Property name inference
93+
## Property Name Inference
9494
In many places `NEST` allows you to pass property names and JSON paths as C# expressions i.e
9595

9696
.Query(q=>q.Term(p=>p.Followers.First().FirstName, "martijn"))
@@ -107,7 +107,7 @@ This will leave property names untouched.
107107

108108
Properties marked with `[ElasticAttibute(Name="")]` or `[JsonProperty(Name="")]` will pass the configured name verbatim.
109109

110-
## Id inference
110+
## Id Inference
111111

112112
Whenever an object is passed that needs to specify an id (i.e index, bulk operations) the object is inspected to see if it has an `Id` property and if so, that value will be used.
113113

new_docs/contents/nest/searching.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
template: layout.jade
3-
title: Connecting
3+
title: Searching
44
menusection: concepts
55
menuitem: searching
66
---

new_docs/contents/nest/writing-queries.markdown

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
template: layout.jade
3-
title: Connecting
3+
title: Writing Queries
44
menusection: concepts
55
menuitem: writing-queries
66
---
@@ -14,7 +14,7 @@ One of the most important things to grasp when using Nest is how to write querie
1414
///EXAMPLE HERE
1515
);
1616

17-
## Raw strings
17+
## Raw Strings
1818
Although not preferred by me personally, many folks like to build their own JSON strings and just pass that along.
1919

2020
.QueryRaw("\"match_all\" : { }")
@@ -25,7 +25,7 @@ Nest does not modify this in anyway and just writes this straight into the JSON
2525
## Query DSL
2626
The preferred way to write queries, since it gives you alot of cool features.
2727

28-
### Lambda expressions
28+
### Lambda Expressions
2929
.Query(q=>q
3030
.Term(p=>p.Name, "NEST")
3131
)
@@ -44,7 +44,7 @@ Of course if you need to pass the property name as string NEST will allow you to
4444
.Term("followers.firstName", "martijn")
4545
)
4646

47-
### Static query/filter generator.
47+
### Static Query/Filter Generator
4848
Sometimes you'll need to resuse a filter or query often. To aid with this you can also write queries like this:
4949

5050
var termQuery = Query<ElasticSearchProject>
@@ -61,7 +61,7 @@ Sometimes you'll need to resuse a filter or query often. To aid with this you ca
6161

6262
Similarly `Filter<T>.[Filter]()` methods exist for filters.
6363

64-
### Boolean queries
64+
### Boolean Queries
6565
As can be seen in the previous example writing out boolean queries can turn into a really tedious and verbose effort. Luckily NEST supports bitwise operators and so we can rewrite the previous as such:
6666

6767
.Query(q=>q.MatchAll() && termQuery)
@@ -96,7 +96,7 @@ You can mix and match this to any level of complexity until it satisfies your qu
9696

9797
Will query all php clients except 'Elastica` or where the name equals `NEST`.
9898

99-
#### Clean output support
99+
#### Clean Output Support
100100
Normally writing three boolean must clauses looks like this (psuedo code)
101101

102102
must
@@ -114,7 +114,7 @@ A naive implemenation of the bitwise operators would make all the queries sent t
114114

115115
This degrades rather rapidly and makes inspecting generated queries quite a chore. NEST does it's best to detect these cases and will always write them in the first, cleaner form.
116116

117-
## Conditionless queries
117+
## Conditionless Queries
118118

119119
Writing complex boolean queries is one thing, but more often then not you'll want to make decisions on how to query based on user input.
120120

src/Elasticsearch.Net/Connection/HttpConnection.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,9 @@ protected virtual HttpWebRequest CreateWebRequest(Uri uri, string method, byte[]
178178
myReq.Accept = requestSpecificConfig.ContentType;
179179
myReq.ContentType = requestSpecificConfig.ContentType;
180180
}
181-
var timeout = this.ConnectionSettings.Timeout;
182-
if (requestSpecificConfig != null && requestSpecificConfig.RequestTimeout.HasValue)
183-
timeout = requestSpecificConfig.RequestTimeout.Value;
184-
185-
myReq.Timeout = timeout; // 1 minute timeout.
186-
myReq.ReadWriteTimeout = timeout; // 1 minute timeout.
181+
var timeout = GetRequestTimeout(requestSpecificConfig);
182+
myReq.Timeout = timeout;
183+
myReq.ReadWriteTimeout = timeout;
187184
myReq.Method = method;
188185

189186
//WebRequest won't send Content-Length: 0 for empty bodies
@@ -251,7 +248,7 @@ protected virtual Task<ElasticsearchResponse<Stream>> DoAsyncRequest(HttpWebRequ
251248
|| this._resourceLock == null)
252249
return this.CreateIterateTask(request, data, requestSpecificConfig, tcs);
253250

254-
var timeout = this.ConnectionSettings.Timeout;
251+
var timeout = GetRequestTimeout(requestSpecificConfig);
255252
var path = request.RequestUri.ToString();
256253
var method = request.Method;
257254
if (!this._resourceLock.WaitOne(timeout))
@@ -280,9 +277,8 @@ private Task<ElasticsearchResponse<Stream>> CreateIterateTask(HttpWebRequest req
280277

281278
private IEnumerable<Task> _AsyncSteps(HttpWebRequest request, TaskCompletionSource<ElasticsearchResponse<Stream>> tcs, byte[] data, IRequestConfiguration requestSpecificConfig)
282279
{
283-
var timeout = this.ConnectionSettings.Timeout;
284-
if (requestSpecificConfig != null && requestSpecificConfig.ConnectTimeout.HasValue)
285-
timeout = requestSpecificConfig.ConnectTimeout.Value;
280+
var timeout = GetRequestTimeout(requestSpecificConfig);
281+
286282
if (data != null)
287283
{
288284
var getRequestStream = Task.Factory.FromAsync<Stream>(request.BeginGetRequestStream, request.EndGetRequestStream, null);
@@ -320,7 +316,7 @@ private IEnumerable<Task> _AsyncSteps(HttpWebRequest request, TaskCompletionSour
320316
tcs.TrySetResult(cs);
321317
}
322318

323-
public void Iterate(HttpWebRequest request, byte[] data, IEnumerable<Task> asyncIterator, TaskCompletionSource<ElasticsearchResponse<Stream>> tcs)
319+
private void Iterate(HttpWebRequest request, byte[] data, IEnumerable<Task> asyncIterator, TaskCompletionSource<ElasticsearchResponse<Stream>> tcs)
324320
{
325321
var enumerator = asyncIterator.GetEnumerator();
326322
Action<Task> recursiveBody = null;
@@ -353,7 +349,12 @@ public void Iterate(HttpWebRequest request, byte[] data, IEnumerable<Task> async
353349
recursiveBody(null);
354350
}
355351

352+
private int GetRequestTimeout(IRequestConfiguration requestConfiguration)
353+
{
354+
if (requestConfiguration != null && requestConfiguration.ConnectTimeout.HasValue)
355+
return requestConfiguration.RequestTimeout.Value;
356356

357-
357+
return this.ConnectionSettings.Timeout;
358+
}
358359
}
359360
}

src/Nest/DSL/Filter/FilterDescriptor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ public FilterContainer Terms(Expression<Func<T, object>> fieldDescriptor, IEnume
520520
ITermsFilter filter = new TermsFilterDescriptor();
521521
filter.Field = fieldDescriptor;
522522
filter.Terms = terms;
523+
filter.Execution = Execution;
523524
return this.New(filter, f=>f.Terms = filter);
524525
}
525526

@@ -531,6 +532,7 @@ public FilterContainer Terms(string field, IEnumerable<string> terms, TermsExecu
531532
ITermsFilter filter = new TermsFilterDescriptor();
532533
filter.Field = field;
533534
filter.Terms = terms ?? Enumerable.Empty<string>();
535+
filter.Execution = Execution;
534536
return this.New(filter, f=>f.Terms = filter);
535537
}
536538

src/Tests/Nest.Tests.Integration/Failover/FailoverPingTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@ public void FailoverShouldOnlyPingDeadNodes()
3333
metrics.Requests.Count.Should().Be(4);
3434
metrics.Requests[0].Node.Port.Should().Be(9202);
3535
metrics.Requests[0].RequestType.Should().Be(RequestType.Ping);
36-
metrics.Requests[0].EllapsedMilliseconds.Should().BeLessOrEqualTo(100);
36+
metrics.Requests[0].EllapsedMilliseconds.Should().BeLessOrEqualTo(200);
3737
metrics.Requests[1].Node.Port.Should().Be(9201);
3838
metrics.Requests[1].RequestType.Should().Be(RequestType.Ping);
39-
metrics.Requests[1].EllapsedMilliseconds.Should().BeLessOrEqualTo(100);
39+
metrics.Requests[1].EllapsedMilliseconds.Should().BeLessOrEqualTo(200);
4040
metrics.Requests[2].Node.Port.Should().Be(9200);
4141
metrics.Requests[2].RequestType.Should().Be(RequestType.Ping);
42-
metrics.Requests[2].EllapsedMilliseconds.Should().BeLessOrEqualTo(100);
42+
metrics.Requests[2].EllapsedMilliseconds.Should().BeLessOrEqualTo(200);
4343
metrics.Requests[3].Node.Port.Should().Be(9200);
4444
metrics.Requests[3].RequestType.Should().Be(RequestType.ElasticsearchCall);
45-
metrics.Requests[3].EllapsedMilliseconds.Should().BeLessOrEqualTo(100);
45+
metrics.Requests[3].EllapsedMilliseconds.Should().BeLessOrEqualTo(200);
4646

4747
rootNode = client.RootNodeInfo();
4848
metrics = rootNode.ConnectionStatus.Metrics;

src/Tests/Nest.Tests.MockData/Domain/ElasticsearchProject.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,7 @@ public class ElasticsearchProject
5555

5656
[ElasticProperty(Type=FieldType.Object)]
5757
public Product Product { get; set; }
58+
59+
public string[] MyStringArrayField { get; set; }
5860
}
5961
}

src/Tests/Nest.Tests.Unit/Search/Filter/Singles/TermsFilterJson.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,52 @@ public void TermsFilterWithCache()
5252
Assert.True(json.JsonEquals(expected), json);
5353
}
5454

55+
[Test]
56+
public void TermsFilter_EnumerableOfStringOverLoad_WithNonDefaultExecutionSpecified_AppliesExecution()
57+
{
58+
var s = new SearchDescriptor<ElasticsearchProject>()
59+
.From(0)
60+
.Size(10)
61+
.Filter(ff => ff
62+
.Terms(f => f.MyStringArrayField, new[] { "elasticsearch.pm" }, Execution: TermsExecution.Bool)
63+
);
64+
65+
var json = TestElasticClient.Serialize(s);
66+
var expected = @"{ from: 0, size: 10,
67+
filter : {
68+
terms: {
69+
""myStringArrayField"": [""elasticsearch.pm""],
70+
execution: ""bool""
71+
}
72+
73+
}
74+
}";
75+
Assert.True(json.JsonEquals(expected), json);
76+
}
77+
78+
[Test]
79+
public void TermsFilter_NonLambdaField_WithNonDefaultExecutionSpecified_AppliesExecution()
80+
{
81+
var s = new SearchDescriptor<ElasticsearchProject>()
82+
.From(0)
83+
.Size(10)
84+
.Filter(ff => ff
85+
.Terms("myStringArrayField", new[] { "elasticsearch.pm" }, Execution: TermsExecution.Bool)
86+
);
87+
88+
var json = TestElasticClient.Serialize(s);
89+
var expected = @"{ from: 0, size: 10,
90+
filter : {
91+
terms: {
92+
""myStringArrayField"": [""elasticsearch.pm""],
93+
execution: ""bool""
94+
}
95+
96+
}
97+
}";
98+
Assert.True(json.JsonEquals(expected), json);
99+
}
100+
55101
[Test]
56102
public void TermsFilterWithConditionlessQueryWithCache()
57103
{

src/Tests/Nest.Tests.Unit/Search/SearchOptions/SearchOptionTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ public void TestFieldsWithExclusionsByProperty()
201201
""stupidIntIWantAsLong"",
202202
""myAttachment"",
203203
""myBinaryField"",
204-
""product""
204+
""product"",
205+
""myStringArrayField""
205206
]
206207
}";
207208
Assert.True(json.JsonEquals(expected));

0 commit comments

Comments
 (0)