I'm running into a problem logging messages from a RabbitMQ Bus (yes, i know that's against recommendation) into ElasticSearch via Nest (v7.17.5). 100+ different messages get consumed that all have differing JSON objects that get expanded into individual fields via an ExpandoObject and dynamically/auto-mapped.
Code that converts the JSON object to a ExpandoObject
MessageContents = JsonConvert.DeserializeObject<ExpandoObject>(commonContext.Message.ToString())
Some messages have fields with the same name as another field but a different data type, e.g. Field "messageContents.user" is a text object with a value of "Bob" for one message, but for another message its a object with the value of "{"Name": "Bob", "Guid": '000-0000-000'}" and this is causing the following error.
object mapping for [messageContents.user] tried to parse field [user] as an object, but found a concrete value
Now standardizing the output of the 100+ different services to either be a string or an object on "x" field but not both, is not an option.
So, how can I enforce a field to be an object with the set-up I have or allow for any datatype to be inputted in a field?
Thanks
I've messed around the the mapping but due to the dynamic nature of the messages im at a loss with my current knowledge of NEST/ElasticSearch.