Delete() 공개 메소드

public Delete ( string indexName, string indexType, string>.List keyParentPairs ) : ElasticSearch.Client.Domain.OperateResult
indexName string
indexType string
keyParentPairs string>.List
리턴 ElasticSearch.Client.Domain.OperateResult
예제 #1
0
		public void SimpleTests()
		{
			var indexName = "myindex_" + Guid.NewGuid();
			var indexType = "type";

			var client = new ElasticSearchClient("localhost");

			var result = client.Index(indexName, indexType, "testkey", "{\"a\":\"b\",\"c\":\"d\"}");
			Assert.AreEqual(true, result.Success);

			client.Refresh(indexName);

			var doc = client.Search(indexName, indexType, "c:d");
			Console.WriteLine(doc.Response);
			Assert.AreEqual(1, doc.GetHits().Hits.Count);
			Assert.AreEqual("b", doc.GetHits().Hits[0].Source["a"]);

			client.Delete(indexName, indexType, "testkey");

			client.Refresh(indexName);

			var doc1 = client.Get(indexName, indexType, "testkey");
			Assert.AreEqual(null,doc1);

			client.DeleteIndex(indexName);
		}
		public void TestBulk()
		{
			var client = new ElasticSearchClient("localhost");
			var fields = new Dictionary<string, object>();
			fields.Add("name", "jack");
			fields.Add("age", 25);
			
			var index = "index_123123123121";
			try
			{
				client.DeleteIndex(index);
				client.CreateIndex(index);
			}
			catch (Exception e)
			{
				Console.WriteLine(e);
			}
			var result = client.Bulk(new List<BulkObject>()
			                         	{
			                         		new BulkObject() { Id = "1", Index = index, Type = "type", Fields = fields }, 
											new BulkObject() { Id = "2", Index = index, Type = "type", Fields = fields }, 
											new BulkObject() { Id = "3", Index = index, Type = "type", Fields = fields }
			                         	});
			Assert.AreEqual(true, result.Success);

			client.Refresh();
			var c = client.Count(index, "type", "age:25");
			Assert.AreEqual(3, c);

			result = client.Delete(index, "type", new string[] { "1", "2", "3" });
			Assert.AreEqual(true, result.Success);

			result=client.DeleteIndex(index);
			Assert.AreEqual(true, result.Success);
		}