-
Notifications
You must be signed in to change notification settings - Fork 709
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
Avoiding mixed types in structured objects #553
Comments
Can you give more details about JSON parsers that can not work? It works perfectly here. If you work with NEST, there are known troubles and you have to work around in the parser, like shown in elastic/elasticsearch-net#227 (comment) |
I work with Boon and it raises a ClassCastException when trying to affect a
|
This looks like a bug in your code. |
Well, yes and no. I have a class that accepts an array of string. The JSON provided by the elasticsearch river can be either a string or an array depending on the number of row found in the database. The parser fails since it is only capable of parsing an array and not a single string (and will raise this ClassCastException). I have two workarounds : either I try to fix the parser with a custom serializer (which, as far as I know, is not possible with Boon) or I try to normalize the JSON output. Which is why I'm here. |
"You can completely customize serialization and deserialization." boonproject/boon#268 Anyway, I recommend Jackson, because it comes with the feature, so it's much easier to do array coercion. Example:
|
Jackson is not an option since my project has been using Boon for quite some time now and relies on it. I'll check the custom Boon serializer, thanks. About my question though, is there a way to enforce a consistent data type ? |
Hi there !
As stated in the documentation about structured objects here, elasticsearch-jdbc can map rows as arrays based off the
_id
of the document, which is great. However, as shown in the documentation example, the mapping result produces mixed types. Here's what I'm talking about (shameless copy/paste) :Which will result in :
As you can see,
employee
can contain either a string ("Jones"
) or an array (["Müller","Meier","Schulze"]
).Is there a way to have a consistent result (eg : an array containing
"Jones"
) ? This behavior can be a real headache, especially when working with JSON parsers thart require a specific type (sayString[]
) and will shout at you when reading an unexpected type.Thanks !
The text was updated successfully, but these errors were encountered: