خرید بک لینک

Vote count: 0

I have some records in SQL Server management studio and I want to index them to my ES index. At present I'm indexing them individually which is taking a long time. I would like to bulk index them. I tried using the Bulk Descriptor it is throwing an error saying > the object to index, if id not set manually it will be inferred from the object

below is my code.

string coectionString = ConfigurationManager.CoectionStrings["MyDbCo"].ToString();
                using (cn = new SqlCoection(coectionString))
                {
                    cmd = new SqlCommand();
                    cmd.CommandText = ConfigurationManager.AppSettings["dbName"];
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Coection = cn;

                    cn.Open();

                    //to index the students response into the ES 
                    try
                    {
                        client = ConfigSettings.coection();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message.ToString());
                        throw;
                    }

                    reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            var descriptor = new BulkDescriptor();
                            descriptor.Index<Class1>(b=>b.Document(new Class1
                            {
                                Id = Int32.Parse(reader[0].ToString()),
                                Title = reader[1].ToString(),
                                BodyContent = reader[2].ToString()  
                            }, z => z.Refresh()));
                        }

Client.Bulk(descriptor);

Client settings

        configvalue1 = ConfigurationManager.AppSettings["url"];
        var pool = new SingleNodeCoectionPool(new Uri(configvalue1));
        var defaultIndex = "dbtrial";

        settings = new CoectionSettings(pool)
         .DefaultIndex(defaultIndex)
         .MapDefaultTypeNames(m => m.Add(typeof(Class1), "records"))

        client = new ElasticClient(settings);
        client.createIndex(defaultIndex);

Is there any way other than descriptor to index thousands of documents in a efficient way?

Thanks In Advance

asked 42 secs ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 14 ارديبهشت 1395 ساعت: 15:24

صفحه بندی