當前位置: 首頁>>代碼示例>>C#>>正文


C# ElasticClient.GetMapping方法代碼示例

本文整理匯總了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);
		}
開發者ID:emohebi,項目名稱:elasticsearch-net,代碼行數:10,代碼來源:ExceptionTests.cs

示例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);
		}
開發者ID:emohebi,項目名稱:elasticsearch-net,代碼行數:12,代碼來源:ExceptionTests.cs

示例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);
		}
開發者ID:jeroenheijmans,項目名稱:elasticsearch-net,代碼行數:14,代碼來源:ExceptionTests.cs

示例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);
		}
開發者ID:jeroenheijmans,項目名稱:elasticsearch-net,代碼行數:16,代碼來源:ExceptionTests.cs

示例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);
		}
開發者ID:niemyjski,項目名稱:elasticsearch-net,代碼行數:17,代碼來源:GithubIssue2409.cs


注:本文中的Nest.ElasticClient.GetMapping方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。