-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Deserialization issue when using Fields #590
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
Which version of Elasticsearch are you using? Prior to 1.0 elasticsearch would return fields like this:
NEST prior to 1.0 was trying to be clever and coerce this response into the Elasticsearch 1.0 returns fields always as arrays except for internal fields so it now looks like this:
Which means NEST 1.0 can no longer coerce This means that you now have to loop over
The
Perhaps in this case NEST can try the coercion of fields again though
If anyone has thoughts on how to solve this in a cleaner manner please share! |
I was using the latest 1.0 code. So I guess in ES it is possible to have a document with the same field more than once, so it can return all the values. Is that right? Although that doesn't sound like a very normal use case. Seems like the best solution when trying to use this automatic object mapping would be to grab the first value in each array. Having it return the first value in the array would be much better than it returning null objects. If there is no way to fix this it seems like you should consider disabling the Fields function in NEST since it would never work the way people expect it to? I simply expected it to return fewer fields in my same object. Having to create a different object with arrays for each property is not very user intuitive but I guess as long as you make it very clear in the online doc examples it would be OK. |
A single field can have multiple values, see the full rationale for returning arrays here: Elasticsearch returns a property called hits with some statistics about all the hits and inside of this another property call hits which is an array of metadata, source/fields.
Now as soon as you specify fields elasticsearch no longer returns i.e
This is completely unparseable into the DTO you specify even if it returned a single value instead of an array. NEST 0.12 also would fail for complex field selection like this. .Documents should not return a list of An alternative to fields in Elasticsearch 1.0 is source extraction: Which NEST 1.0.0-beta1 supports and does allow you to reuse your DTO. |
When doing a search the documents all come back as null objects when using "Fields" to select only certain fields. Elasticsearch returns the data correctly but the library does not deserialize the data back in the object type specified, MyObject, in this example.
The text was updated successfully, but these errors were encountered: