Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Nest;
- namespace ConsoleApplication2
- {
- class Program
- {
- class Document
- {
- public string Field1 { get; set; }
- public string Field2 { get; set; }
- public override string ToString()
- {
- return string.Format("{{ Field1: '{0}', Field2: '{1}' }}", Field1, Field2);
- }
- }
- static void Main(string[] args)
- {
- var elasticClient = new ElasticClient(new ConnectionSettings(new Uri("http://localhost:9200"), "test"));
- elasticClient.Index(new Document { Field1 = "Value1", Field2 = "Value2" }, s => s.Id("123"));
- var response = elasticClient.GetMany<Document>(new[] { "123" });
- var response2 = elasticClient.MultiGet(s => s.GetMany<Document>(new[] { "123" }));
- Console.WriteLine("First result");
- foreach (var hit in response)
- {
- Console.WriteLine("Found document with id {0}? {1}", hit.Id, hit.Found ? "Yes" : "No");
- if (hit.Found)
- Console.WriteLine(hit.Source);
- }
- Console.WriteLine("Second result");
- foreach (var hit in response2.Documents)
- {
- Console.WriteLine("Found document with id {0}? {1}", hit.Id, hit.Found ? "Yes" : "No");
- if (hit.Found)
- Console.WriteLine(hit.Source);
- }
- Console.ReadKey(false);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement