spring-projects / spring-data-elasticsearch

Provide support to increase developer productivity in Java when using Elasticsearch. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-elasticsearch/
Apache License 2.0
2.9k stars 1.33k forks source link

Support storeNullValue and storeEmptyValue for property that is annotated with @MultiField annotation #2952

Closed donghuantang closed 4 weeks ago

donghuantang commented 1 month ago

Currently storeNullValue and storeEmptyValue are supported for property that is annotated with the @Field annotation. Need to also add support for property that is annotated with @MultiField annotation. Suggesting the following code change in the SimpleElasticsearchPersistentProperty class:

In the SimpleElasticsearchPersistentProperty constructer, update the assignment of storeNullValue and storeEmptyValue to also check the mainField parameters in the @MultiField annotation:

storeNullValue = (isField && getRequiredAnnotation(Field.class).storeNullValue()) || (isAnnotationPresent(MultiField.class) && getRequiredAnnotation(MultiField.class).mainField().storeNullValue()); storeEmptyValue = isField ? getRequiredAnnotation(Field.class).storeEmptyValue() : isAnnotationPresent(MultiField.class) ? getRequiredAnnotation(MultiField.class).mainField().storeEmptyValue() : true;