2

I am using below code for sorting

//http://10.132.150.186:8010/rest-client/service/movie/romance/hindi/2012/0/10/asc

if($urlParam[1] != 'all')
    $params['body']['query']['filtered']['filter']['and'][]['term']['gener'] = $urlParam[1];

if($urlParam[2] != 'all')
    $params['body']['query']['filtered']['filter']['and'][]['term']['language'] = $urlParam[2];

if($urlParam[3] != 'all')
    $params['body']['query']['filtered']['filter']['and'][]['term']['year'] = $urlParam[3];

if($urlParam[4] != 'all')
    $params['from'] = $urlParam[4];

if($urlParam[5] != 'all')
    $params['size'] = $urlParam[5]; 

if($urlParam[6] != 'all')
    $params['sort']['movieid'] = ['order' => $urlParam[6]]; 

$result = $client->search($params);

Url Is also mentioned in above code,which i am mapping against above code. All conditions are working as expected except 6th condition(i.e. sorting not working).

Below is the output what I am getting

Array
(
    [0] => Array
        (
            [_index] => pvrmod
            [_type] => movie
            [_id] => 22
            [_score] => 1
            [_source] => Array
                (
                    [movieid] => 22
                    [title] => namaste london22
                    [desc] => namaste london description
                    [gener] => romance
                    [language] => hindi
                    [year] => 2012
                    [tags] => Array
                        (
                            [0] => romance
                            [1] => akshay kumar
                            [2] => caterina kaif
                            [3] => romance
                            [4] => hindi
                            [5] => namaste london
                        )

                    [actor] => Array
                        (
                            [0] => akshay kumar
                            [1] => caterina kaif
                        )

                )

        )

    [4] => Array
        (
            [_index] => pvrmod
            [_type] => movie
            [_id] => 29
            [_score] => 1
            [_source] => Array
                (
                    [movieid] => 29
                    [title] => namaste london29
                    [desc] => namaste london description
                    [gener] => romance
                    [language] => hindi
                    [year] => 2012
                    [tags] => Array
                        (
                            [0] => romance
                            [1] => akshay kumar
                            [2] => caterina kaif
                            [3] => romance
                            [4] => hindi
                            [5] => namaste london
                        )

                    [actor] => Array
                        (
                            [0] => akshay kumar
                            [1] => caterina kaif
                        )

                )

        )

    [5] => Array
        (
            [_index] => pvrmod
            [_type] => movie
            [_id] => 21
            [_score] => 1
            [_source] => Array
                (
                    [movieid] => 21
                    [title] => namaste london21
                    [desc] => namaste london description
                    [gener] => romance
                    [language] => hindi
                    [year] => 2012
                    [tags] => Array
                        (
                            [0] => romance
                            [1] => akshay kumar
                            [2] => caterina kaif
                            [3] => romance
                            [4] => hindi
                            [5] => namaste london
                        )

                    [actor] => Array
                        (
                            [0] => akshay kumar
                            [1] => caterina kaif
                        )

                )

        )

)

Please help.

Thanks in advance.

2
  • What's the value of $urlParam[6]? Commented Feb 9, 2016 at 15:31
  • 6th parameter is "asc" Commented Feb 10, 2016 at 9:37

1 Answer 1

2

Got solution.Actually I put condition at wrong place. I need to put $params['body']['sort']['movieid'] = ['order' => $urlParam[6]]; instead of $params['sort']['movieid'] = ['order' => $urlParam[6]];

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.