Skip to content

Conversation

@samsullivan
Copy link
Contributor

Added Sort component for Script Based Sorting.
Source: ElasticSearch Script Based Sorting

@samsullivan
Copy link
Contributor Author

Example, to get:

{
    "query" : {
        ....
    },
    "sort" : {
        "_script" : {
            "script" : "doc['field_name'].value * factor",
            "type" : "number",
            "params" : {
                "factor" : 1.1
            },
            "order" : "asc"
        }
    }
}

Create a Sort object with:

Sherlock::sortBuilder()->Script()
    ->script("doc['field_name'].value * factor")
    ->type('number')
    ->params(array(
        'factor' => 1.1
    ))
    ->order('asc');

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.

1 participant