Example #1
0
 private IElasticClient GetElasticClient(ICargoEsRepositoryConfigSection config)
 {
     return(new ElasticClient(
                new ConnectionSettings(new Uri(config.ServerUrl))
                .DefaultIndex(config.DefaultIndex)
                .DisableDirectStreaming()
                .OnRequestCompleted(details =>
     {
         if (config.EnableTraceMode)
         {
             Debug.WriteLine("### ES REQEUST ###");
             if (details.RequestBodyInBytes != null)
             {
                 Debug.WriteLine(Encoding.UTF8.GetString(details.RequestBodyInBytes));
             }
             Debug.WriteLine("### ES RESPONSE ###");
             if (details.ResponseBodyInBytes != null)
             {
                 Debug.WriteLine(Encoding.UTF8.GetString(details.ResponseBodyInBytes));
             }
         }
     })
                .PrettyJson()
                ));
 }
Example #2
0
        public CargoEsRepository(ICargoEsRepositoryConfigSection config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            this.client = GetElasticClient(config);
        }