Skip to content

Commit 8a8ae27

Browse files
committed
updated asciidocs
1 parent b939669 commit 8a8ae27

File tree

6 files changed

+36
-23
lines changed

6 files changed

+36
-23
lines changed

docs/aggregations/writing-aggregations.asciidoc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ return s => s
144144
);
145145
----
146146
<1> a list of aggregation functions to apply
147-
148147
<2> Using LINQ's `Aggregate()` function to accumulate/apply all of the aggregation functions
149148

150149
Combining multipe `AggregationDescriptor`'s is also possible using the bitwise `&` operator
@@ -212,6 +211,5 @@ var maxPerChild = childAggregation.Max("max_per_child");
212211
maxPerChild.Should().NotBeNull(); <2>
213212
----
214213
<1> Do something with the average per child. Here we just assert it's not null
215-
216214
<2> Do something with the max per child. Here we just assert it's not null
217215

docs/client-concepts/connection-pooling/request-overrides/disable-sniff-ping-per-request.asciidoc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ new ClientCall()
6464
);
6565
----
6666
<1> disable sniffing
67-
6867
<2> first call is a successful ping
69-
7068
<3> sniff on startup call happens here, on the second call
7169

7270
Now, let's disable pinging on the request
@@ -89,7 +87,6 @@ audit = await audit.TraceCall(
8987
);
9088
----
9189
<1> disable ping
92-
9390
<2> No ping after sniffing
9491

9592
Finally, let's demonstrate disabling both sniff and ping on the request
@@ -111,6 +108,5 @@ audit = await audit.TraceCall(
111108
);
112109
----
113110
<1> diable ping and sniff
114-
115111
<2> no ping or sniff before the call
116112

docs/client-concepts/high-level/inference/field-inference.asciidoc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -500,13 +500,9 @@ class Precedence
500500
}
501501
----
502502
<1> Even though this property has a NEST property mapping _and_ a `JsonProperty` attribute, We are going to provide a hard rename for it on ConnectionSettings later that should win.
503-
504503
<2> This property has both a NEST attribute and a `JsonProperty`, NEST should win.
505-
506504
<3> We should take the json property into account by itself
507-
508505
<4> This property we are going to special case in our custom serializer to resolve to ask
509-
510506
<5> We are going to register a DefaultFieldNameInferrer on ConnectionSettings that will uppercase all properties.
511507

512508
Here we create a custom serializer that renames any property named `AskSerializer` to `ask`

docs/client-concepts/high-level/inference/indices-paths.asciidoc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ ISearchRequest singleTypedRequest = new SearchDescriptor<Project>().Index(single
7474
var invalidSingleString = Nest.Indices.Index("name1, name2"); <3>
7575
----
7676
<1> specifying a single index using a string
77-
7877
<2> specifying a single index using a type
79-
8078
<3> an **invalid** single index name
8179

8280
==== Specifying multiple indices
@@ -100,9 +98,7 @@ ISearchRequest manyTypedRequest = new SearchDescriptor<Project>().Index(manyType
10098
((IUrlParameter)manyTypedRequest.Index).GetString(client.ConnectionSettings).Should().Be("project,devs"); <3>
10199
----
102100
<1> specifying multiple indices using strings
103-
104101
<2> specifying multiple indices using types
105-
106102
<3> The index names here come from the Connection Settings passed to `TestClient`. See the documentation on <<index-name-inference, Index Name Inference>> for more details.
107103

108104
==== Specifying All Indices

docs/client-concepts/low-level/connecting.asciidoc

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -314,24 +314,47 @@ therefore **we recommend doing some minimal introspection on the passed in certi
314314
If running on Core CLR, then a custom connection type must be created by deriving from `HttpConnection` and
315315
overriding the `CreateHttpClientHandler` method in order to set the `ServerCertificateCustomValidationCallback` property.
316316

317-
=== Overriding default Json.NET behavior
317+
=== Overriding Json.NET settings
318318

319319
Overriding the default Json.NET behaviour in NEST is an expert behavior but if you need to get to the nitty gritty, this can be really useful.
320-
First, create a subclass of the `JsonNetSerializer`
320+
321+
The easiest way is to create an instance of `SerializerFactory` that allows you to register a modification callback
322+
in the constructor
323+
324+
[source,csharp]
325+
----
326+
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
327+
328+
var connectionSettings = new ConnectionSettings(
329+
pool,
330+
new HttpConnection(),
331+
new SerializerFactory((jsonSettings, nestSettings) => jsonSettings.PreserveReferencesHandling = PreserveReferencesHandling.All));
332+
333+
var client = new ElasticClient(connectionSettings);
334+
----
335+
336+
A more involved and explicit way would be to implement your own JsonNetSerializer subclass.
337+
338+
NOTE: this is subject to change in the next major release. NEST relies heavily on stateful deserializers (that have access to the original
339+
request) for specialized features such a covariant search results. This requirement leaks into this abstraction.
321340

322341
[source,csharp]
323342
----
324343
public class MyJsonNetSerializer : JsonNetSerializer
325344
{
326-
public MyJsonNetSerializer(IConnectionSettingsValues settings) : base(settings) { }
345+
public MyJsonNetSerializer(IConnectionSettingsValues settings)
346+
: base(settings, (s, csv) => s.PreserveReferencesHandling = PreserveReferencesHandling.All) <1>
347+
{
348+
OverwriteDefaultSerializers((s, cvs) => ModifySerializerSettings(s)); <2>
349+
}
327350
328351
public int CallToModify { get; set; } = 0;
329352
330-
protected override void ModifyJsonSerializerSettings(JsonSerializerSettings settings) => ++CallToModify; <1>
353+
private void ModifySerializerSettings(JsonSerializerSettings settings) => ++CallToModify;
331354
332355
public int CallToContractConverter { get; set; } = 0;
333356
334-
protected override IList<Func<Type, JsonConverter>> ContractConverters => new List<Func<Type, JsonConverter>> <2>
357+
protected override IList<Func<Type, JsonConverter>> ContractConverters => new List<Func<Type, JsonConverter>> <3>
335358
{
336359
t => {
337360
CallToContractConverter++;
@@ -341,9 +364,11 @@ public class MyJsonNetSerializer : JsonNetSerializer
341364
342365
}
343366
----
344-
<1> Override ModifyJsonSerializerSettings if you need access to `JsonSerializerSettings`
367+
<1> Call this constructor if you only need access to `JsonSerializerSettings` without local state
368+
369+
<2> Call OverwriteDefaultSerializers if you need access to `JsonSerializerSettings` with local state
345370

346-
<2> You can inject contract resolved converters by implementing the ContractConverters property. This can be much faster then registering them on `JsonSerializerSettings.Converters`
371+
<3> You can inject contract resolved converters by implementing the ContractConverters property. This can be much faster then registering them on `JsonSerializerSettings.Converters`
347372

348373
You can then register a factory on `ConnectionSettings` to create an instance of your subclass instead.
349374
This is **_called once per instance_** of ConnectionSettings.

src/Tests/ClientConcepts/LowLevel/Connecting.doc.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,15 @@ public void EasyWay()
315315
*
316316
* NOTE: this is subject to change in the next major release. NEST relies heavily on stateful deserializers (that have access to the original
317317
* request) for specialized features such a covariant search results. This requirement leaks into this abstraction.
318+
*
319+
*
318320
*/
319321
public class MyJsonNetSerializer : JsonNetSerializer
320322
{
321323
public MyJsonNetSerializer(IConnectionSettingsValues settings)
322-
: base(settings, (s, csv) => s.PreserveReferencesHandling = PreserveReferencesHandling.All) //<1> Call this constructor if you only need access to `JsonSerializerSettings` without state
324+
: base(settings, (s, csv) => s.PreserveReferencesHandling = PreserveReferencesHandling.All) //<1> Call this constructor if you only need access to `JsonSerializerSettings` without local state
323325
{
324-
OverwriteDefaultSerializers((s, cvs) => ModifySerializerSettings(s)); //<2> Call OverwriteDefaultSerializers if you need access to `JsonSerializerSettings` with state
326+
OverwriteDefaultSerializers((s, cvs) => ModifySerializerSettings(s)); //<2> Call OverwriteDefaultSerializers if you need access to `JsonSerializerSettings` with local state
325327
}
326328

327329
public int CallToModify { get; set; } = 0;

0 commit comments

Comments
 (0)