Example #1
0
        static void InsertWeibo4()
        {
            ESFactory.Add("http://localhost:9200");
            var store = ESFactory.CreateStore <Weibo>();

            store.Add(CreateWeibo("InsertWeibo4"), "weibo");

            Console.WriteLine("InsertWeibo4");
        }
Example #2
0
        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");
        }