Beispiel #1
0
        internal bool Update(string id,string time)
        {
            var connectionSettings = new ConnectionSettings(MainVariables.conElasticSearch);
            connectionSettings.SetDefaultIndex("websites");
            connectionSettings.MapDefaultTypeNames(m => m.Add(typeof(websites), "list"));
            var elasticClient = new ElasticClient(connectionSettings);
            var index = elasticClient.Update<websites, object>(u => u
            .Id(id)
            .Doc(new {last_run=DateTime.Now, Scrapping_Time=time })
            .RetryOnConflict(3)
            .Refresh()
            );
            // var index = elasticClient.Update<websites, object>(u => u .IdFrom(obj).Doc(new { website_url = "United States" }).DocAsUpsert());
               // var index = elasticClient.Index(obj);
             //var index=   elasticClient.Update<websites, object>(u => u.Upsert(new websites { _id = "AVFX2hdEYZh0OvPHWO7l", website_url = "http://www.google.com" }));
            if (index.ServerError == null && index.ConnectionStatus.HttpStatusCode.Value < 203) return true;

            else return false;
        }