Skip to content

storeNullValue doesn't work since 5.0 #2839

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

Closed
BernardLM opened this issue Jan 30, 2024 · 1 comment · Fixed by #2841
Closed

storeNullValue doesn't work since 5.0 #2839

BernardLM opened this issue Jan 30, 2024 · 1 comment · Fixed by #2841
Assignees
Labels
type: bug A general bug

Comments

@BernardLM
Copy link

BernardLM commented Jan 30, 2024

Hello

I am working on a SpringBoot 2.6 (using spring-data-elasticsearch 4.4.3) API
that needs to store null values explicitly

for that we are using storeNullValue attribute from Field annotation, added to 4.1
@JsonProperty(value = "longdescr") @Field(name = "longdescr", storeNullValue = true) private String longDescription;

Upgrading to SpringBoot 3.1 (using spring-data-elasticsearch 5.1)
null values are not indexed to elastic anymore.

I tested spring-data-elasticsearch from v5.0 to 5.2.2 without success

storeNullValue attribute is taken in account in MappingElasticSearchConcverter.java (5.1)

`

if (value == null) {
  if (property.storeNullValue()) {
	  sink.set(property, null);
  }

  continue;

}

`

and this part is setting property to null as expected, as of my debugger.

According to results found over the net, this param is not popularly used.

Anyone experienced that issue ?
Anyone is using storeNullValue param proerly on v5 ?

Note that according to my tests, it is not related to ES

  • my ES is still able to store null values from a direct POST.
  • SpringBoot 2.6 is adding null values on both ES7 and ES8 instances.
  • SpringBoot 3.1 is not adding null values on niether ES7 neither ES8.

thanks for caring :)
Bernard

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 30, 2024
@sothawo sothawo added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 30, 2024
@sothawo
Copy link
Collaborator

sothawo commented Jan 30, 2024

This is not working since switching to the new Elasticsearch client library in 5.0. Obviously nobody noticed until you did now.
I need to check if I can find a way to customize the internally used ObjectMapper.

@sothawo sothawo self-assigned this Jan 30, 2024
sothawo added a commit that referenced this issue Jan 31, 2024
Original Pull Request #2841
Closes #2839
sothawo added a commit to sothawo/spring-data-elasticsearch that referenced this issue Jan 31, 2024
Original Pull Request spring-projects#2841
Closes spring-projects#2839

(cherry picked from commit 0a1e205)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants