本文整理汇总了C#中Nest.ElasticClient.GetMapping方法的典型用法代码示例。如果您正苦于以下问题:C# ElasticClient.GetMapping方法的具体用法?C# ElasticClient.GetMapping怎么用?C# ElasticClient.GetMapping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nest.ElasticClient
的用法示例。
在下文中一共展示了ElasticClient.GetMapping方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ServerTestWhenThrowExceptionsDisabled
//[I]
public void ServerTestWhenThrowExceptionsDisabled()
{
var settings = new ConnectionSettings(new Uri("http://ipv4.fiddler:9200"));
var client = new ElasticClient(settings);
var response = client.GetMapping<Project>(s => s.Index("doesntexist"));
response.CallDetails.OriginalException.Should().NotBeNull();
response.CallDetails.ServerError.Should().NotBeNull();
response.CallDetails.ServerError.Status.Should().BeGreaterThan(0);
}
示例2: ServerTestWhenThrowExceptionsEnabled
//[I]
public void ServerTestWhenThrowExceptionsEnabled()
{
var settings = new ConnectionSettings(new Uri("http://ipv4.fiddler:9200"))
.ThrowExceptions();
var client = new ElasticClient(settings);
var exception = Assert.Throws<ElasticsearchClientException>(() => client.GetMapping<Project>(s => s.Index("doesntexist")));
exception.InnerException.Should().NotBeNull();
exception.Response.Should().NotBeNull();
exception.Response.ServerError.Should().NotBeNull();
exception.Response.ServerError.Status.Should().BeGreaterThan(0);
}
示例3: ServerTestWhenThrowExceptionsDisabled
public void ServerTestWhenThrowExceptionsDisabled()
{
var settings = new ConnectionSettings(new Uri($"http://{TestClient.Host}:{_port}"));
var client = new ElasticClient(settings);
var response = client.GetMapping<Project>(s => s.Index("doesntexist"));
#if DOTNETCORE
// HttpClient does not throw on "known error" status codes (i.e. 404) thus OriginalException should not be set
response.CallDetails.OriginalException.Should().BeNull();
#else
response.CallDetails.OriginalException.Should().NotBeNull();
#endif
response.CallDetails.ServerError.Should().NotBeNull();
response.CallDetails.ServerError.Status.Should().BeGreaterThan(0);
}
示例4: ServerTestWhenThrowExceptionsEnabled
public void ServerTestWhenThrowExceptionsEnabled()
{
var settings = new ConnectionSettings(new Uri($"http://{TestClient.Host}:{_port}"))
.ThrowExceptions();
var client = new ElasticClient(settings);
var exception = Assert.Throws<ElasticsearchClientException>(() => client.GetMapping<Project>(s => s.Index("doesntexist")));
#if DOTNETCORE
// HttpClient does not throw on "known error" status codes (i.e. 404) thus the inner exception should not be set
exception.InnerException.Should().BeNull();
#else
exception.InnerException.Should().NotBeNull();
#endif
exception.Response.Should().NotBeNull();
exception.Response.ServerError.Should().NotBeNull();
exception.Response.ServerError.Status.Should().BeGreaterThan(0);
}
示例5: CanDeserializeCopyTo
public void CanDeserializeCopyTo()
{
var json = "{\"test-events-v1-201412\":{\"mappings\":{\"events\":{\"dynamic\":\"false\",\"_size\":{\"enabled\":true},\"properties\":{\"created_utc\":{\"type\":\"date\"},\"data\":{\"properties\":{\"@environment\":{\"properties\":{\"o_s_name\":{\"type\":\"text\",\"index\":false,\"copy_to\":[\"os\"]}}}}},\"id\":{\"type\":\"keyword\"},\"os\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\",\"ignore_above\":256}}}}}}},\"test-events-v1-201502\":{\"mappings\":{\"events\":{\"dynamic\":\"false\",\"_size\":{\"enabled\":true},\"properties\":{\"created_utc\":{\"type\":\"date\"},\"data\":{\"properties\":{\"@environment\":{\"properties\":{\"o_s_name\":{\"type\":\"text\",\"index\":false,\"copy_to\":[\"os\"]}}}}},\"id\":{\"type\":\"keyword\"},\"os\":{\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\",\"ignore_above\":256}}}}}}}}";
var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));
var connection = new InMemoryConnection(Encoding.UTF8.GetBytes(json));
var settings = new ConnectionSettings(pool, connection).DefaultIndex("test-events-v1-201412");
var client = new ElasticClient(settings);
var mappingResponse = client.GetMapping<Events>();
mappingResponse.IsValid.Should().BeTrue();
var mappingWalker = new MappingWalker(new CopyToVisitor());
mappingWalker.Accept(mappingResponse);
}