static void Main(string[] args) { Console.WriteLine("Hello World!"); ESFactory.Add("http://localhost:9200"); var query = ESFactory.Create <Book>(); var list = query.Where(book => book.Id == 1).ToList(); int count = list.Count; Console.WriteLine($"query.Where(book => book.Id == 1).ToList() count:{count}"); query.Clear(); list = query.MatchAll().ToList(); count = list.Count; Console.WriteLine($"query.MatchAll().ToList() count:{count}"); query.Clear(); list = query.Where(book => book.Title == "").ToList(); count = list.Count; Console.WriteLine($"query.Where(book=>book.Title==\"\").ToList() count:{count}"); query.Clear(); list = query.Where(book => book.Created > DateTime.Now.AddDays(-1)).ToList(); count = list.Count; Console.WriteLine($"query.Where(book => book.Created >DateTime.Now.AddDays(-1)).ToList() count:{count}"); }
static void InsertWeibo4() { ESFactory.Add("http://localhost:9200"); var store = ESFactory.CreateStore <Weibo>(); store.Add(CreateWeibo("InsertWeibo4"), "weibo"); Console.WriteLine("InsertWeibo4"); }
static void InsertWeibo2() { ESFactory.Add("http://localhost:9200"); var store = ESFactory.CreateStore <Weibo>(); Weibo weibo = CreateWeibo(""); store.Add(weibo, "weibo", f => f.ArticleSequenceId); List <Weibo> list = new List <Weibo>(); foreach (var i in Enumerable.Range(0, 10)) { list.Add(CreateWeibo("list-" + i)); } store.Add(list, "weibo", f => f.ArticleSequenceId); //store.Remove(weibo, "weibo"); //store.Remove(weibo.ArticleSequenceId, "weibo", "weibo"); var list2 = new object[] { weibo.ArticleSequenceId }; store.Remove(list2, "weibo"); //store.Remove(list); var query = ESFactory.Create <Weibo>(); var list4 = query .Index("weibo") .Ids(new string[] { list.First().ArticleSequenceId.ToString() }) .ToList(); if (list.Count > 0) { var model = list.First(); model.Class1 = "AAAAAAAAAAA2"; model.Class2 = "bbbbbbbbbbbb2"; //store.Update(model, f => f.ArticleSequenceId, "weibo"); store.Update(new Weibo[] { model }, f => f.ArticleSequenceId, "weibo"); } Console.WriteLine("InsertWeibo2"); }