-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Problem with accessing fields via dynamic object #620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @sporty81 A hit actually looks like this so
So the right lookup should be:
Also note the lowercase H on the first I've attached a commit to this issue with two tests to try and reproduce the exception but I'm not able to reproduce it. Can you have a look ? |
So in my fork of the code it throws an error. In my copy of your repository with these tests it does not. I tried to get my fork to update to latest and thought I had it but I guess not. So maybe it is working fine. Something in my fork is out of sync with the code base. But these are good unit tests to have for sure. |
They are :) Let me know if you find out what it was in your fork. |
The library makes extensive use of dynamic objects. There is a problem with this in the current implementation. When doing something like a search that can return various fields depending on if a document has the field or not, it does not work. Take the example below. Let's pretend sometimes "testfield" is in the document and sometime it is not. There is no way to do hit["testfield"] != null or hit.ContainsKey("testfield") to see if the field exists.
Ultimately it is throwing an exception in here (ElasticDynamicValue) when it tries to call the underlying SimpleJson.JObject
Possible fixes
Something like this would fix it but it sort of feels like a hack. Hopefully whoever designed all this dynamic stuff has a better understanding and other thoughts on the right way to do this.
The text was updated successfully, but these errors were encountered: