Skip to content

Commit 62a0309

Browse files
committed
Build docs
1 parent 2c4c37f commit 62a0309

File tree

3 files changed

+39
-20
lines changed

3 files changed

+39
-20
lines changed

Diff for: docs/build/nest/connecting.html

+22-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,28 @@ <h2 id="changing-the-underlying-connection">Changing the underlying connection</
1616
<pre><code>var client = new ElasticClient(settings, new ThriftConnection(settings));
1717
</code></pre><p>NEST comes with an Http Connection <code>HttpConnection</code>, Thrift Connection <code>ThriftConnection</code>
1818
and an In-Memory Connection <code>InMemoryConnection</code>, that nevers hits Elasticsearch.</p>
19-
<h2 id="settings">Settings</h2>
19+
<p>You can also roll your own connection if desired by implementing the <code>IConnection</code> interface.</p>
20+
<h2 id="subclassing-existing-connection-implementations">Subclassing existing connection implementations</h2>
21+
<p>In addition to implementing your own <code>IConnection</code>, the existing <code>HttpConnection</code> and <code>ThriftConnection</code> are extendible and can be subclassed in order to modify or extend their behavior.</p>
22+
<p>For instance, a common use case is the ability to add client certificates to web requests. You can subclass <code>HttpConnection</code> and override the <code>CreateHttpWebRequest</code> method that creates the web request, and add certificates to it like so:</p>
23+
<pre><code>public class SignedHttpConnection : HttpConnection
24+
{
25+
private readonly X509CertificateCollection _certificates;
26+
27+
public SignedHttpConnection(IConnectionConfigurationValues settings, X509CertificateCollection certificates)
28+
: base(settings)
29+
{
30+
_certificates = certificates;
31+
}
32+
33+
protected override HttpWebRequest CreateHttpWebRequest(Uri uri, string method, byte[] data, IRequestConfiguration requestSpecificConfig)
34+
{
35+
var request = base.CreateHttpWebRequest(uri, method, data, requestSpecificConfig);
36+
request.ClientCertificates = _certificates;
37+
return request;
38+
}
39+
}
40+
</code></pre><h2 id="settings">Settings</h2>
2041
<p>The <code>NEST</code> client can be configured by passing in an <code>IConnectionSettingsValues</code> object, which is a sub-interface of
2142
<code>Elasticsearch.Net</code>&#39;s <code>IConnectionConfigurationValues</code>. Therefore all of the settings that can be used to
2243
<a href="/elasticsearch-net/connection.html">configure Elasticsearch.Net</a> also apply here, including the

Diff for: docs/build/nest/indices/create-indices.html

+8-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
<h2 id="note">Note</h2>
55
<p>When adding settings strip the <code>index.</code> prefix. This applies to settings found in the <a href="http://www.elasticsearch.org/guide/reference/index-modules/">Index Module</a> documentation.</p>
66
<h2 id="simple-example">Simple example</h2>
7-
<pre><code>var client = this.ConnectedClient;
8-
var settings = new IndexSettings();
7+
<pre><code>var settings = new IndexSettings();
98
settings.NumberOfReplicas = 1;
109
settings.NumberOfShards = 5;
11-
settings.Add(&quot;merge.policy.merge_factor&quot;,&quot;10&quot;);
12-
settings.Add(&quot;search.slowlog.threshold.fetch.warn&quot;, &quot;1s&quot;);
13-
client.CreateIndex(&quot;myindexname&quot;, settings);
10+
settings.Settings.Add(&quot;merge.policy.merge_factor&quot;,&quot;10&quot;);
11+
settings.Settings.Add(&quot;search.slowlog.threshold.fetch.warn&quot;, &quot;1s&quot;);
12+
13+
client.CreateIndex(c =&gt; c
14+
.Index(&quot;myindexname&quot;)
15+
.InitializeUsing(settings)
16+
);
1417
</code></pre><h2 id="create-index-with-settings-and-mappings-in-one-go-fluently">Create index with settings and mappings in one go fluently</h2>
1518
<pre><code>client.CreateIndex(&quot;myindexname&quot;, c =&gt; c
1619
.NumberOfReplicas(0)

Diff for: docs/build/nest/indices/put-mapping.html

+9-14
Original file line numberDiff line numberDiff line change
@@ -41,39 +41,34 @@ <h2 id="attribute-based-mapping">Attribute based mapping</h2>
4141
<p><strong>ALSO NOTE</strong>: <code>Map&lt;T&gt;()</code> will also explicitly map string properties as strings with elasticsearch even if they do not have an attribute on them. It does this for all the value types (string, int, float, double, DateTime).</p>
4242
<h2 id="code-based-mapping">Code based mapping</h2>
4343
<p>You can also create mappings on the fly:</p>
44-
<pre><code>var typeMapping = new TypeMapping(Guid.NewGuid().ToString(&quot;n&quot;));
45-
var property = new TypeMappingProperty
44+
<pre><code>var indexDefinition = new RootObjectMapping
4645
{
47-
Type = &quot;multi_field&quot;
46+
Properties = new Dictionary&lt;PropertyNameMarker, IElasticType&gt;(),
47+
Name = indexName
4848
};
4949

50-
var primaryField = new TypeMappingProperty
50+
var property = new StringMapping
5151
{
52-
Type = &quot;string&quot;,
5352
Index = &quot;not_analyzed&quot;
5453
};
5554

56-
var analyzedField = new TypeMappingProperty
55+
var analyzedField = new StringMapping
5756
{
58-
Type = &quot;string&quot;,
5957
Index = &quot;analyzed&quot;
6058
};
6159

62-
property.Fields = new Dictionary&lt;string, TypeMappingProperty&gt;();
63-
property.Fields.Add(&quot;name&quot;, primaryField);
6460
property.Fields.Add(&quot;name_analyzed&quot;, analyzedField);
65-
66-
typeMapping.Properties.Add(&quot;name&quot;, property);
67-
this.ConnectedClient.Map(typeMapping);
61+
indexDefinition.Properties.Add(&quot;name&quot;, property);
62+
this.ConnectedClient.Map&lt;object&gt;(x =&gt; x.InitializeUsing(indexDefinition));
6863
</code></pre><h2 id="multifield-mapping">Multifield Mapping</h2>
6964
<p>To create multifield type you can use following example. </p>
7065
<pre><code>var result = this._client.Map&lt;ElasticsearchProject&gt;(m =&gt; m
7166
.Properties(props =&gt; props
72-
.MultiField(s =&gt; s
67+
.String(s =&gt; s
7368
.Name(p =&gt; p.Name)
7469
.Path(MultiFieldMappingPath.Full)
70+
.Index(FieldIndexOption.not_analyzed)
7571
.Fields(pprops =&gt; pprops
76-
.String(ps =&gt; ps.Name(p =&gt; p.Name).Index(FieldIndexOption.not_analyzed))
7772
.String(ps =&gt; ps.Name(p =&gt; p.Name.Suffix(&quot;searchable&quot;)).Index(FieldIndexOption.analyzed))
7873
)
7974
))

0 commit comments

Comments
 (0)