Deserialize different typed field to other typed property in Nest

Hi,
We just recently upgraded from 6.3 to 7.7 version of Elasticsearch.

Upon migration, we got an error something like this:
"{"expected:'Number Token', actual:'"10"' at offset:458"}"

Based on a blog I've read, bluewalk replied to the problem was:

*Seems the new serializer takes the property datatype for deserialization, as this was defined as long instead of string the deserializer failed. *
Can be closed :slight_smile:

Now, is there a way to deserialize object field that has been mapped in the index as "Text" to "integer" or other type in Nest? And can you give me an example on implementing it.

Thanks and regards,
Martin

Hi Martin,

One option would be changing your POCO to reflect the property as a string. I presume that's not possible here for some reason? You could of course parse that to a long in a computed property if it's needed in that form.

You could also look at plugging in a custom serialiser to control the behaviour for your types as you require. Using the JSON.NET serialiser which handles string to numeric conversions will probably work.

Cheers,
Steve

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.