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
I did some investigation and noticed that when we moved the populateScriptFields method from using ReflectionUtils to PersitenceEntity on 9d57410, this condition:
if (property.isAnnotationPresent(ScriptedField.class) && fields.containsKey(property.getName())) {
will never be true for custom names,since property#getNames is unaware of the ScriptedField annotation. In the previous example, it will always return scriptedFieldProperty instead of the expected scripted-field-property
I can see two ways of solving the issue.
Remove the second part of the conditional and do the check internally. The name should come first from the annotation and only fall back to the property if it is not set. (Note this is already done before setting the value)
Make SimpleElasticsearchPersistentProperty aware of the ScriptedField annotation. By adding a condition to check it in SimpleElasticsearchPersistentProperty#getAnnotatedFieldName, we can also ensure that the property has the correct name when populating the scripted fields.
I'm unsure of any other valid solution and would love some input. I have both solutions implemented locally and can create a PR if needed
I just noticed that if we set a custom name for a scripted field, it won't be mapped correctly to the entity in question while reading it.
Example:
I did some investigation and noticed that when we moved the
populateScriptFields
method from usingReflectionUtils
toPersitenceEntity
on 9d57410, this condition:will never be true for custom names,since
property#getNames
is unaware of theScriptedField
annotation. In the previous example, it will always returnscriptedFieldProperty
instead of the expectedscripted-field-property
I can see two ways of solving the issue.
SimpleElasticsearchPersistentProperty
aware of the ScriptedField annotation. By adding a condition to check it inSimpleElasticsearchPersistentProperty#getAnnotatedFieldName
, we can also ensure that the property has the correct name when populating the scripted fields.I'm unsure of any other valid solution and would love some input. I have both solutions implemented locally and can create a PR if needed
Update: created a PR with the changes here #3023
The text was updated successfully, but these errors were encountered: