1

I am creating a dynamic object. I assign the values via IDictionary. Add the collections of the IDictionary to the object. Then I add the dynamic object to Elastic Search using NEST code. It throws me stackoverflow exception."An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll"

Here is what I have tried.

 var node = new Uri("http://localhost:9200");
            var settings = new ConnectionSettings(node,defaultIndex: "test-index");
            var client = new ElasticClient(settings);

            try
            {
                dynamic x = new ExpandoObject();
                Dictionary<string, object> dic = new Dictionary<string, object>();
                dic.Add("NewProp", "test1");
                dic.Add("NewProp3", "test1");
                x = dic;
                var index3 = client.Index(x);
            }
            catch (Exception ex)
            {
                string j = ex.StackTrace;
            }

I need to create an index in ElasticSearch, using a dynamic object, because I will be having an excel work book consisting of over 300 worksheet, and each and every sheet will be named as type, and the contents inside the worksheet will be the _source.

In the above example 'x' the dynamic object created is the name of the worksheet, and the values added into the dictionary are the rows and columns of excel sheet.

Where am I going wrong.

Regards, Hema

1 Answer 1

2

I belive you can skip ExpandoObject and just index Dictionary<string, object>().

var dictionary = new Dictionary<string, object>();
dictionary.Add("NewProp", "test1");
dictionary.Add("NewProp3", "test1");

client.Index(dictionary);
Sign up to request clarification or add additional context in comments.

2 Comments

Are you getting exception? May you post more details?
Sorry Rob, issue in my system, I deleted some files, along with marvel logs, due to which the Index Response was returning null. Thanks a ton!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.