Пример #1
0
        public static ElasticsearchResponse <DynamicDictionary> IndexAlbum(string url)
        {
            var uri    = new Uri(url);
            var config = new ConnectionConfiguration(uri);

            config.ExposeRawResponse(true);
            var client = new ElasticsearchClient(config);

            // 'dynamically'-typed
            Console.WriteLine(" --- 'dynamically'-typed --- ");
            ElasticsearchResponse <DynamicDictionary> response = client.Index("rolling-stone-500", "album", "1", Album.ChronicleV1);

            Console.WriteLine("_index: " + response.Response["_index"]);
            Console.WriteLine("_type: " + response.Response["_type"]);
            Console.WriteLine("_id: " + response.Response["_id"]);
            Console.WriteLine("_version: " + response.Response["_version"]);
            Console.WriteLine("created: " + response.Response["created"]);

            // strongly-typed
            Console.WriteLine(" --- strongly-typed --- ");
            ElasticsearchResponse <Album> response2 = client.Index <Album>("rolling-stone-500", "album", "2", Album.ChronicleV1);

            //Console.WriteLine("_index: " + response2.Response._index);
            //Console.WriteLine("_type: " + response2.Response._type);
            //Console.WriteLine("_id: " + response2.Response._id);
            //Console.WriteLine("_version: " + response2.Response._version);
            // Console.WriteLine("created: " + response2.Response.created);  // removed this because it's getting indexed as well -- only want it to pick up the response

            // show raw response (requires config on connection)
            Console.WriteLine(" --- raw response --- ");
            Console.WriteLine(Encoding.UTF8.GetString(response2.ResponseRaw));

            return(response);
        }
Пример #2
0
        public static void GetAlbum(string url)
        {
            var uri    = new Uri(url);
            var config = new ConnectionConfiguration(uri);

            config.ExposeRawResponse(true);
            var client = new ElasticsearchClient(config);

            // 'dynamically'-typed
            Console.WriteLine(" --- 'dynamically'-typed --- ");

            ElasticsearchResponse <DynamicDictionary> response = client.Get("rolling-stone-500", "album", "59");

            Console.WriteLine("_index: " + response.Response["_index"]);
            Console.WriteLine("_type: " + response.Response["_type"]);
            Console.WriteLine("_id: " + response.Response["_id"]);
            Console.WriteLine("_version: " + response.Response["_version"]);
            Console.WriteLine("found: " + response.Response["found"]);
            Console.WriteLine("_source: " + response.Response ["_source"]);

            // strongly-typed
            Console.WriteLine(" --- strongly-typed --- ");
            ElasticsearchResponse <Album> response2 = client.Get <Album>("rolling-stone-500", "album", "59");

            // NOTE: all the below is returning as null or empty -- needs more investigation as to why
            Console.WriteLine();
            Console.WriteLine("SOURCE: ");
            Console.WriteLine("Title: {0}", response2.Response.Title);
            Console.WriteLine("Url: {0}", response2.Response.Url);
            Console.WriteLine("Artist: {0}", response2.Response.Artist);
            Console.WriteLine("Rank: {0}", response2.Response.Rank);
            Console.WriteLine("Label: {0}", response2.Response.Label);
            Console.WriteLine("Year: {0}", response2.Response.Year);
            Console.WriteLine("Summary: {0}", response2.Response.Summary);
            Console.WriteLine("ImageUrl: {0}", response2.Response.ImageUrl);

            // show raw response (requires config on connection)
            Console.WriteLine(" --- raw response --- ");
            Console.WriteLine(Encoding.UTF8.GetString(response2.ResponseRaw));
        }
Пример #3
0
 /// <summary>
 /// Enabling configuration settings prior to receive internal API call timings.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="configuration"></param>
 internal static void ApplyConfigurationSettings <T>(ConnectionConfiguration <T> configuration) where T : ConnectionConfiguration <T>
 {
     configuration.EnableMetrics();
     configuration.ExposeRawResponse();
 }