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

search() exception when specifing a complex "sort" #34

Closed
lifo101 opened this issue Dec 23, 2013 · 1 comment
Closed

search() exception when specifing a complex "sort" #34

lifo101 opened this issue Dec 23, 2013 · 1 comment

Comments

@lifo101
Copy link

lifo101 commented Dec 23, 2013

I can not apply a sort using the Elasticsearch\Client::search method as outlined below. The bug appears to be in AbstractEndpoint::convertArraysToStrings and it incorrectly attempts to implode() any nested array into a comma separated list but the 'sort' search criteria can be a simple string or another nested array of parameters.

$es = new Elasticsearch\Client();
print_r($es->search(array(
    'index' => 'my_index',
    'type' => 'my_type',
    'sort' => array(
        // 'aFieldName', // this would work ... the next line doesn't
        'dateCreated' => array( 'order' => 'desc' ),
    ),
    'body' => array(
        'query' => array(
            'query_string' => array(
                'query' => 'search term'
            )
        )
    )
)));
@polyfractal
Copy link
Contributor

Thanks for the report! Looks like this would have affected other "complex" parameters like filter or facet. Bug fixed and a few tests added. Let me know if you run into any more problems!

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

No branches or pull requests

2 participants