Skip to content

Commit 0ed05c3

Browse files
authored
Include similarity in index settings (#2924) (#2966)
Non binary breaking back port of 648c3cf Similarity settings are nested under settings>index Add ClassicSimilarity Add DFISimilarity Add similarity settings to create index integration tests Add XML comments for each similarity Refactor SimilarityJsonConverter to not look up the NEST ISimilarity type with Type.GetType() but to infer it from the type property value directly. Add Similarity to the updatable index settings Closes #2890 (cherry picked from commit bf78582)
1 parent c1b0706 commit 0ed05c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+828
-343
lines changed

docs/aggregations/writing-aggregations.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ return s => s
172172
);
173173
----
174174
<1> a list of aggregation functions to apply
175+
175176
<2> Using LINQ's `Aggregate()` function to accumulate/apply all of the aggregation functions
176177

177178
Combining multiple `AggregationDescriptor` is also possible using the bitwise `&&` operator
@@ -237,5 +238,6 @@ var maxPerChild = childAggregation.Max("max_per_child");
237238
maxPerChild.Should().NotBeNull(); <2>
238239
----
239240
<1> Do something with the average per child. Here we just assert it's not null
241+
240242
<2> Do something with the max per child. Here we just assert it's not null
241243

docs/client-concepts/certificates/working-with-certificates.asciidoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,11 @@ public class PkiCluster : CertgenCaCluster
144144
}
145145
----
146146
<1> Set the client certificate on `ConnectionSettings`
147+
147148
<2> The path to the `.cer` file
149+
148150
<3> The path to the `.key` file
151+
149152
<4> The password for the private key
150153

151154
Or per request on `RequestConfiguration` which will take precedence over the ones defined on `ConnectionConfiguration`

docs/client-concepts/connection-pooling/exceptions/unexpected-exceptions.asciidoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ audit = await audit.TraceUnexpectedException(
6060
);
6161
----
6262
<1> set up a cluster with 10 nodes
63+
6364
<2> where node 2 on port 9201 always throws an exception
65+
6466
<3> The first call to 9200 returns a healthy response
67+
6568
<4> ...but the second call, to 9201, returns a bad response
6669

6770
Sometimes, an unexpected exception happens further down in the pipeline. In this scenario, we
@@ -100,7 +103,9 @@ audit = await audit.TraceUnexpectedException(
100103
);
101104
----
102105
<1> calls on 9200 set up to throw a `WebException`
106+
103107
<2> calls on 9201 set up to throw an `Exception`
108+
104109
<3> Assert that the audit trail for the client call includes the bad response from 9200 and 9201
105110

106111
An unexpected hard exception on ping and sniff is something we *do* try to recover from and failover to retrying on the next node.
@@ -145,6 +150,8 @@ audit = await audit.TraceUnexpectedException(
145150
);
146151
----
147152
<1> `InnerException` is the exception that brought the request down
153+
148154
<2> The hard exception that happened on ping is still available though
155+
149156
<3> An exception can be hard to relate back to a point in time, so the exception is also available on the audit trail
150157

docs/client-concepts/connection-pooling/exceptions/unrecoverable-exceptions.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ var audit = new Auditor(() => Framework.Cluster
6868
);
6969
----
7070
<1> Always succeed on ping
71+
7172
<2> ...but always fail on calls with a 401 Bad Authentication response
7273

7374
Now, let's make a client call. We'll see that the first audit event is a successful ping
@@ -88,7 +89,9 @@ audit = await audit.TraceElasticsearchException(
8889
);
8990
----
9091
<1> First call results in a successful ping
92+
9193
<2> Second call results in a bad response
94+
9295
<3> The reason for the bad response is Bad Authentication
9396

9497
When a bad authentication response occurs, the client does not attempt to deserialize the response body returned;
@@ -122,6 +125,7 @@ audit = await audit.TraceElasticsearchException(
122125
);
123126
----
124127
<1> Always return a 401 bad response with a HTML response on client calls
128+
125129
<2> Assert that the response body bytes are null
126130

127131
Now in this example, by turning on `DisableDirectStreaming()` on `ConnectionSettings`, we see the same behaviour exhibited
@@ -154,5 +158,6 @@ audit = await audit.TraceElasticsearchException(
154158
);
155159
----
156160
<1> Response bytes are set on the response
161+
157162
<2> Assert that the response contains `"nginx/"`
158163

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@ audit = await audit.TraceCalls(
6767
);
6868
----
6969
<1> disable sniffing
70+
7071
<2> first call is a successful ping
72+
7173
<3> sniff on startup call happens here, on the second call
74+
7275
<4> No sniff on startup again
7376

7477
Now, let's disable pinging on the request
@@ -92,6 +95,7 @@ audit = await audit.TraceCall(
9295
);
9396
----
9497
<1> disable ping
98+
9599
<2> No ping after sniffing
96100

97101
Finally, let's demonstrate disabling both sniff and ping on the request
@@ -113,5 +117,6 @@ audit = await audit.TraceCall(
113117
);
114118
----
115119
<1> diable ping and sniff
120+
116121
<2> no ping or sniff before the call
117122

docs/client-concepts/connection-pooling/round-robin/skip-dead-nodes.asciidoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ await audit.TraceCalls(
142142
);
143143
----
144144
<1> The first call goes to 9200 which succeeds
145+
145146
<2> The 2nd call does a ping on 9201 because its used for the first time. It fails so we wrap over to node 9202
147+
146148
<3> The next call goes to 9203 which fails so we should wrap over
147149

148150
A cluster with 2 nodes where the second node fails on ping
@@ -192,5 +194,6 @@ await audit.TraceCalls(
192194
);
193195
----
194196
<1> All the calls fail
197+
195198
<2> After all our registered nodes are marked dead we want to sample a single dead node each time to quickly see if the cluster is back up. We do not want to retry all 4 nodes
196199

docs/client-concepts/high-level/analysis/writing-analyzers.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ var createIndexResponse = client.CreateIndex("my-index", c => c
102102
);
103103
----
104104
<1> Pre-defined list of English stopwords within Elasticsearch
105+
105106
<2> Use the `standard_english` analyzer configured
106107

107108
[source,javascript]
@@ -267,6 +268,7 @@ var createIndexResponse = client.CreateIndex("questions", c => c
267268
);
268269
----
269270
<1> Use an analyzer at index time that strips HTML tags
271+
270272
<2> Use an analyzer at search time that does not strip HTML tags
271273

272274
With this in place, the text of a question body will be analyzed with the `index_question` analyzer

docs/client-concepts/high-level/getting-started.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ var indexResponse = client.Index(person); <1>
109109
var asyncIndexResponse = await client.IndexAsync(person); <2>
110110
----
111111
<1> synchronous method that returns an `IIndexResponse`
112+
112113
<2> asynchronous method that returns a `Task<IIndexResponse>` that can be awaited
113114

114115
NOTE: All methods available within NEST are exposed as both synchronous and asynchronous versions,

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,9 +473,13 @@ class Precedence
473473
}
474474
----
475475
<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.
476+
476477
<2> This property has both a NEST attribute and a `JsonProperty`, NEST should win.
478+
477479
<3> We should take the json property into account by itself
480+
478481
<4> This property we are going to special case in our custom serializer to resolve to ask
482+
479483
<5> We are going to register a DefaultFieldNameInferrer on ConnectionSettings that will uppercase all properties.
480484

481485
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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ singleIndexFromIndexName.Match(
9090
);
9191
----
9292
<1> `_all` will override any specific index names here
93+
9394
<2> The `Project` type has been mapped to a specific index name using <<index-name-type-mapping,`.InferMappingFor<Project>`>>
9495

9596
[[nest-indices]]
@@ -120,7 +121,9 @@ ISearchRequest singleTypedRequest = new SearchDescriptor<Project>().Index(single
120121
var invalidSingleString = Nest.Indices.Index("name1, name2"); <3>
121122
----
122123
<1> specifying a single index using a string
124+
123125
<2> specifying a single index using a type
126+
124127
<3> an **invalid** single index name
125128

126129
===== Multiple indices
@@ -145,7 +148,9 @@ manyStringRequest = new SearchDescriptor<Project>().Type(new[] { "name1", "name2
145148
((IUrlParameter)manyStringRequest.Type).GetString(client.ConnectionSettings).Should().Be("name1,name2");
146149
----
147150
<1> specifying multiple indices using strings
151+
148152
<2> specifying multiple indices using types
153+
149154
<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.
150155

151156
===== All Indices

0 commit comments

Comments
 (0)