Skip to content

ResponseConverter not set updated value #3108

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wp2code opened this issue May 13, 2025 · 4 comments · Fixed by #3109
Closed

ResponseConverter not set updated value #3108

wp2code opened this issue May 13, 2025 · 4 comments · Fixed by #3109
Labels
type: bug A general bug

Comments

@wp2code
Copy link

wp2code commented May 13, 2025

src/main/java/org/springframework/data/elasticsearch/client/elc/ResponseConverter.java

the updated value is not set in the method byQueryResponse

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 13, 2025
@sothawo
Copy link
Collaborator

sothawo commented May 13, 2025

Please provide a minimal, runnable example showing the problem you encounter

@sothawo sothawo added the status: waiting-for-feedback We need additional information before we can continue label May 13, 2025
@wp2code
Copy link
Author

wp2code commented May 14, 2025

package com.demo;
import co.elastic.clients.elasticsearch._types.query_dsl.IdsQuery;
import co.elastic.clients.elasticsearch._types.query_dsl.QueryBuilders;
import jakarta.annotation.Resource;
import lombok.Data;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.client.elc.NativeQuery;
import org.springframework.data.elasticsearch.core.query.ByQueryResponse;
import org.springframework.data.elasticsearch.core.query.UpdateQuery;
import org.springframework.util.Assert;

@SpringBootTest
public class UpdateServiceTest {
    
    @Resource
    private ElasticsearchTemplate template;
    @Test
    public void testUpdateByQuery() {
        final IdsQuery query = QueryBuilders.ids().values("1").build();
        final NativeQuery nativeQuery = NativeQuery.builder().withQuery(query._toQuery()).withFields("id", "name").build();
        final UpdateQuery updateQuery = UpdateQuery.builder(nativeQuery).build();
        final ByQueryResponse byQueryResponse = template.updateByQuery(updateQuery, template.getIndexCoordinatesFor(Model.class));
        Assert.isTrue(byQueryResponse.getUpdated() > 0,"updated value is zero");
    }
    
    @Data
    @Document(indexName = "doc_model")
    public static class Model {
        
        @Id
        private String id;
        
        private String name;
    }
}

I found that the updated value was not set in method byQueryResponse
Image

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels May 14, 2025
@sothawo
Copy link
Collaborator

sothawo commented May 14, 2025

Now I see what you mean: the org.springframework.data.elasticsearch.core.query.ByQueryResponse#updated property is not set with the value returned in the co.elastic.clients.elasticsearch.core.UpdateByQueryResponse#updated object

@sothawo sothawo added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels May 14, 2025
sothawo added a commit to sothawo/spring-data-elasticsearch that referenced this issue May 14, 2025
Closes spring-projects#3108
Signed-off-by: Peter-Josef Meisch <pj.meisch@sothawo.com>
@sothawo sothawo added this to the 5.5 GA (2025.0.0) milestone May 14, 2025
sothawo added a commit that referenced this issue May 14, 2025
Original Pull Request #3109
Closes #3108

Signed-off-by: Peter-Josef Meisch <pj.meisch@sothawo.com>
(cherry picked from commit ebbe242)
sothawo added a commit that referenced this issue May 14, 2025
Original Pull Request #3109
Closes #3108

Signed-off-by: Peter-Josef Meisch <pj.meisch@sothawo.com>
(cherry picked from commit ebbe242)
(cherry picked from commit ea51ce0)
@sothawo
Copy link
Collaborator

sothawo commented May 14, 2025

implemented in main and backported to 5.4x. and 5.3.x branches

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants