You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
because it tries to instantiate the target entity without all the required parameters.
Looking further into the code, I saw that it tries to add the script_fields later on, with the populateScriptFields method, but only if this condition is not met, which led me to modify my class to look like this
Since this is an issue that can occur both in Kotlin & Java, I think having some documentation of this would be great. It could help other people that might get into the same issue I did.
The other solution could be to combine the fields of the Document with the source and let ElasticsearchPropertyValueProvider handle all of it. But that one requires much more work.
Affects: 4.0.3 (Neumann SR3)
The text was updated successfully, but these errors were encountered:
Thanks for looking into this, I also think that solution is a better approach. Btw, I found another quirk that might be solved alongside this initial issue.
If the scripted_field is not a primitive type but rather a complex type as a GeoPoint the populateScriptFields does not work as expected. eg: @Document(indexName = "test")
data class Test(@Id var id: String) { @ScriptedField val point: GeoPoint}
and let's suppose that our scripted field return something that looks like
{
"lon": -171.050373,
"lat": 22.340608
}
The reflection will fail, so I solve this by using a field to hold the raw data and a second field that constructs the proper object by delegation. @Document(indexName = "test")
data class Test(@Id var id: String) { @ScriptedField private val _point: Map<String,Double>
val point: Money by lazy {
return GeoPoint(_point["lat"], _point["lng"])
}}
Not the cleanest solution, but works for me. Let me know if I can help somehow
Alfonso Gonzalez Luis opened DATAES-915 and commented
I found that when I have a document that looks like, this:
and try to make a search like
the conversion fails on
because it tries to instantiate the target entity without all the required parameters.
Looking further into the code, I saw that it tries to add the script_fields later on, with the populateScriptFields method, but only if this condition is not met, which led me to modify my class to look like this
Since this is an issue that can occur both in Kotlin & Java, I think having some documentation of this would be great. It could help other people that might get into the same issue I did.
The other solution could be to combine the fields of the Document with the source and let ElasticsearchPropertyValueProvider handle all of it. But that one requires much more work.
Affects: 4.0.3 (Neumann SR3)
The text was updated successfully, but these errors were encountered: