コード例 #1
0
        public static void BulkType(List <Bic_Iban_Codes> ModelData, ElasticConnection connection, PlainElastic.Net.Serialization.JsonNetSerializer serializer, string _index)
        {
            string bulkCommand = new BulkCommand(index: _index, type: "iban_bic").Refresh();

            string bulkJson = new BulkBuilder(serializer)
                              .BuildCollection(ModelData, (builder, pro) => builder.Index(data: pro, id: pro.CodeID.ToString())
                                               );

            string     result     = connection.Post(bulkCommand, bulkJson);
            BulkResult bulkResult = serializer.ToBulkResult(result);

            connection.Post(_index + "/_refresh");
        }
コード例 #2
0
        public static void BulkType <T>(List <T> Model, ElasticConnection connection, PlainElastic.Net.Serialization.JsonNetSerializer serializer, string _index, string _type) where T : IElasticMapper
        {
            string bulkCommand = "";

            bulkCommand = new BulkCommand(index: _index, type: _type).Refresh();
            string bulkJson = new BulkBuilder(serializer)
                              .BuildCollection(Model, (builder, pro) => builder.Index(data: pro, id: pro.id)
                                               );
            string     result     = connection.Post(bulkCommand, bulkJson);
            BulkResult bulkResult = serializer.ToBulkResult(result);

            connection.Post(_index + "/_refresh");
        }
コード例 #3
0
        private static void BulkTweetIndex(IEnumerable<Tweet> tweets, ElasticConnection connection, JsonNetSerializer serializer)
        {
            string bulkCommand = new BulkCommand(index: "twitter", type: "tweet").Refresh();

            int id = 10; // start adding tweets from id = 10 
            string bulkJson = new BulkBuilder(serializer)
                                    .BuildCollection(tweets, 
                                    (builder, tweet) => builder.Index(data: tweet, id: (id++).AsString())
                                    );
            
            string result = connection.Post(bulkCommand, bulkJson);

            //Parse bulk result;
            BulkResult bulkResult = serializer.ToBulkResult(result);

            PrintBulkCommand(bulkCommand, bulkJson, bulkResult);
        }