Skip to content

Support for lists when fetching the value of a runtime field that contains multiple values #3076

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
dimitra-konstantinidou opened this issue Mar 10, 2025 · 2 comments · Fixed by #3080
Labels
type: enhancement A general enhancement

Comments

@dimitra-konstantinidou
Copy link

We have a runtime field that contains multiple string values. Currently the getFieldValue method returns only the first value of the field. Could you please provide support for returning lists as well?

Thank you.

public interface SearchDocument extends Document {
    float getScore();

    Map<String, List<Object>> getFields();

    @Nullable
    default <V> V getFieldValue(final String name) {
        List<Object> values = (List)this.getFields().get(name);
        return (V)(values != null && !values.isEmpty() ? values.get(0) : null);
    }
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 10, 2025
@sothawo sothawo added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 11, 2025
@sothawo
Copy link
Collaborator

sothawo commented Mar 11, 2025

Adding that to the SearchDocument is the obvious part; I'll see how this can be extended to populate list (collection?) runtime fields in the rerturned entity.

sothawo added a commit to sothawo/spring-data-elasticsearch that referenced this issue Mar 18, 2025
sothawo added a commit that referenced this issue Mar 18, 2025
Original Pull Request #3080
Closes #3076

Signed-off-by: Peter-Josef Meisch <[email protected]>
@sothawo sothawo added this to the 5.5 RC1 (2025.0.0) milestone Mar 18, 2025
@dimitra-konstantinidou
Copy link
Author

Thank you!

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

Successfully merging a pull request may close this issue.

3 participants