当前位置: 首页>>代码示例>>C#>>正文


C# IElasticClient.Index方法代码示例

本文整理汇总了C#中IElasticClient.Index方法的典型用法代码示例。如果您正苦于以下问题:C# IElasticClient.Index方法的具体用法?C# IElasticClient.Index怎么用?C# IElasticClient.Index使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IElasticClient的用法示例。


在下文中一共展示了IElasticClient.Index方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IndexItems

        public static void IndexItems(IElasticClient client)
        {
            for (var i = 0; i < 5; i++)
            {
                var j = i + 1;
                var person = new Person
                {
                    Id = j,
                    Firstname = string.Format("Martijn{0}", j),
                    Lastname = string.Format("{0}Laarman", j)
                };

                if (ValidateIfIdIsAlreadyUsedForIndex(j, client))
                {
                    client.Index(person);
                }
            }
        }
开发者ID:dynamicdeploy,项目名称:Elastic-Searcher,代码行数:18,代码来源:Utils.cs

示例2: TestIndex

        private static void TestIndex(IElasticClient elastic)
        {
            var blogPost = new BlogPost
            {
                Id = Guid.NewGuid(),
                Title = "First blog post",
                Body = "This is very long blog post!"
            };

            var firstId = blogPost.Id;

            var indexResult = elastic.Index(blogPost, p => p
                .Id(blogPost.Id.ToString())
                .Refresh());

            Console.WriteLine(indexResult.ApiCall.Success);

            var resDel = elastic.Delete<BlogPost>(firstId.ToString());

            Console.WriteLine(resDel.ApiCall.Success);
        }
开发者ID:tuvoksg1,项目名称:ProvingGround,代码行数:21,代码来源:Program.cs

示例3: CreateRandomBlogs

        private static void CreateRandomBlogs(IElasticClient elastic)
        {
            var blogPosts = new[]
            {
                new BlogPost {Id = Guid.NewGuid(), Title = "test post 123", Body = "1"},
                new BlogPost {Id = Guid.NewGuid(), Title = "test something 123", Body = "2"},
                new BlogPost {Id = Guid.NewGuid(), Title = "read this post", Body = "3"},
                new BlogPost {Id = Guid.NewGuid(), Title = "read my blog", Body = "4"},
                new BlogPost {Id = Guid.NewGuid(), Title = "post from jason", Body = "5"},
                new BlogPost {Id = Guid.NewGuid(), Title = "private blog", Body = "6"}
            };

            foreach (var blogPost in blogPosts)
            {
                elastic.Index(blogPost, p => p
                    .Id(blogPost.Id.ToString())
                    .Refresh());
            }
        }
开发者ID:tuvoksg1,项目名称:ProvingGround,代码行数:19,代码来源:Program.cs

示例4: CreatBlogPostBatch

 private static void CreatBlogPostBatch(IElasticClient elastic)
 {
     for (var index = 0; index < 10; index++)
     {
         var blogPost = new BlogPost
         {
             Id = Guid.NewGuid(),
             Title = $"title {index:000}",
             Body = $"This is {index:000} very long blog post!"
         };
         elastic.Index(blogPost, p => p
             .Id(blogPost.Id.ToString())
             .Refresh());
     }
 }
开发者ID:tuvoksg1,项目名称:ProvingGround,代码行数:15,代码来源:Program.cs

示例5: CreateNestedBlogs

        private static void CreateNestedBlogs(IElasticClient elastic)
        {
            var author1 = new Author {Id = Guid.NewGuid(), FirstName = "John", LastName = "Doe"};
            var author2 = new Author {Id = Guid.NewGuid(), FirstName = "Notjohn", LastName = "Doe"};
            var author3 = new Author {Id = Guid.NewGuid(), FirstName = "John", LastName = "Notdoe"};

            var blogPosts = new[]
            {
                new BlogPost {Id = Guid.NewGuid(), Title = "test post 1", Body = "1", Author = author1},
                new BlogPost {Id = Guid.NewGuid(), Title = "test post 2", Body = "2", Author = author2},
                new BlogPost {Id = Guid.NewGuid(), Title = "test post 3", Body = "3", Author = author3}
            };

            foreach (var blogPost in blogPosts)
            {
                elastic.Index(blogPost, p => p
                    .Id(blogPost.Id.ToString())
                    .Refresh());
            }

            //add blog with missing property
            var author4 = new Author
            {
                Id = Guid.NewGuid(),
                FirstName = "John",
                LastName = "Doe"
            };

            var blogPost1 = new BlogPost
            {
                Id = Guid.NewGuid(),
                Title = "test post 1",
                Body = null,
                Author = author4
            };

            elastic.Index(blogPost1, p => p
               .Id(blogPost1.Id.ToString())
               .Refresh());

            Console.WriteLine("Nested blogs indexed");
        }
开发者ID:tuvoksg1,项目名称:ProvingGround,代码行数:42,代码来源:Program.cs


注:本文中的IElasticClient.Index方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。