Skip to content
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

Add support for script based sorting in SortBuilder #131

Merged

Conversation

yonghee12
Copy link

Implements #130

This PR introduces support for script-based sorting in SortBuilder, in addition to the existing field name-based sorting functionality.

With this change, you can now sort documents using custom scripts.

For example:

SearchDSL().apply {
    sort {
        addScript(
            order = SortOrder.ASC,
            type = "number",
            source = "doc['field_name'].value * params.factor;",
            lang = "painless",
            params = mapOf("factor" to 1.1),
        )
        add(
            field = "field_name",
            order = SortOrder.DESC,
            mode = SortMode.AVG,
        )
    }
}

@jillesvangurp jillesvangurp merged commit db436a8 into jillesvangurp:master Apr 15, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants