Get() public method

public Get ( string index, string type, string indexKey, string routing = null ) : ElasticSearch.Client.Domain.Document
index string
type string
indexKey string
routing string
return ElasticSearch.Client.Domain.Document
Exemplo n.º 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);
		}
Exemplo n.º 2
0
        public void CanIndexGetGemsGame()
        {
            var id = Guid.NewGuid().ToString();

            var client = new ElasticSearchClient("ec2-107-22-42-34.compute-1.amazonaws.com", 9500, TransportType.Thrift);
            var data = new Dictionary<string, object> {{"GameId", "asdf"}};

            var bulkObject = new BulkObject("gems","gameindex" , id, data);

            client.Bulk(new List<BulkObject> {bulkObject});

            var loaded = client.Get("gems", "gameindex", id);

            Assert.IsNotNull(loaded);
            Assert.IsNotNull(loaded.GetFields());
            Assert.AreEqual("asdf", loaded.GetFields()["GameId"]);
        }