cakephp / elastic-search

Elastic search datasource for CakePHP
Other
88 stars 53 forks source link

Pagination #86

Closed gieart87 closed 4 years ago

gieart87 commented 8 years ago

I had a problem about pagination in elastic . I try to send a parameter "?page = 2" when using mysql running normally . But when using elastic it does not work .

{
    "message": "Not Found",
    "url": "\/myapp\/api\/categories.json?limit=3\u0026amp;page=2",
    "code": 404,
    "trace": [
        {
            "file": "\/var\/www\/html\/myapp\/vendor\/cakephp\/cakephp\/src\/Controller\/Controller.php",
            "line": 688,
            "function": "paginate",
            "class": "Cake\\Controller\\Component\\PaginatorComponent",
            "type": "-\u003E",
            "args": [
                {

                },
                {
                    "limit": 3
                }
            ]
        },
        {`
markstory commented 8 years ago

What is the -\u003E doing in there?

gieart87 commented 8 years ago

That is debug trace of cakephp , I do not know what causes it elastic

markstory commented 8 years ago

Ok. Is there anything more to that trace?

gieart87 commented 8 years ago

This is the full trace :

{
    "message": "Not Found",
    "url": "/bot/viglink/cakeviglink/api/categories.json?page=2",
    "code": 404,
    "trace": [
        {
            "file": "/var/www/html/bot/viglink/cakeviglink/vendor/cakephp/cakephp/src/Controller/Controller.php",
            "line": 688,
            "function": "paginate",
            "class": "Cake\\Controller\\Component\\PaginatorComponent",
            "type": "->",
            "args": [
                {},
                {
                    "limit": 3
                }
            ]
        },
        {
            "file": "/var/www/html/bot/viglink/cakeviglink/src/Controller/Api/CategoriesController.php",
            "line": 39,
            "function": "paginate",
            "class": "Cake\\Controller\\Controller",
            "type": "->",
            "args": [
                {}
            ]
        },
        {
            "file": "/var/www/html/bot/viglink/cakeviglink/vendor/cakephp/cakephp/src/Controller/Controller.php",
            "line": 429,
            "function": "call_user_func_array",
            "args": [
                [
                    {
                        "components": {
                            "RequestHandler": null
                        },
                        "name": "Categories",
                        "helpers": [],
                        "request": {
                            "params": {
                                "plugin": null,
                                "controller": "Categories",
                                "action": "index",
                                "_ext": "json",
                                "pass": [],
                                "_method": "GET",
                                "prefix": "api",
                                "isAjax": false,
                                "paging": {
                                    "categories": {
                                        "finder": "all",
                                        "page": 1,
                                        "current": 3,
                                        "count": 3,
                                        "perPage": 3,
                                        "prevPage": false,
                                        "nextPage": false,
                                        "pageCount": 1,
                                        "sort": null,
                                        "direction": false,
                                        "limit": null,
                                        "sortDefault": false,
                                        "directionDefault": false
                                    }
                                }
                            },
                            "data": [],
                            "query": {
                                "page": "2"
                            },
                            "cookies": [],
                            "url": "api/categories.json",
                            "base": "/bot/viglink/cakeviglink",
                            "webroot": "/bot/viglink/cakeviglink/",
                            "here": "/bot/viglink/cakeviglink/api/categories.json",
                            "trustProxy": false
                        },
                        "response": {},
                        "paginate": {
                            "limit": 3
                        },
                        "autoRender": true,
                        "View": null,
                        "plugin": null,
                        "passedArgs": [],
                        "modelClass": "Categories",
                        "viewClass": null,
                        "viewVars": [],
                        "RequestHandler": {
                            "enabled": true,
                            "response": {},
                            "ext": "json",
                            "request": {
                                "params": {
                                    "plugin": null,
                                    "controller": "Categories",
                                    "action": "index",
                                    "_ext": "json",
                                    "pass": [],
                                    "_method": "GET",
                                    "prefix": "api",
                                    "isAjax": false,
                                    "paging": {
                                        "categories": {
                                            "finder": "all",
                                            "page": 1,
                                            "current": 3,
                                            "count": 3,
                                            "perPage": 3,
                                            "prevPage": false,
                                            "nextPage": false,
                                            "pageCount": 1,
                                            "sort": null,
                                            "direction": false,
                                            "limit": null,
                                            "sortDefault": false,
                                            "directionDefault": false
                                        }
                                    }
                                },
                                "data": [],
                                "query": {
                                    "page": "2"
                                },
                                "cookies": [],
                                "url": "api/categories.json",
                                "base": "/bot/viglink/cakeviglink",
                                "webroot": "/bot/viglink/cakeviglink/",
                                "here": "/bot/viglink/cakeviglink/api/categories.json",
                                "trustProxy": false
                            },
                            "components": []
                        },
                        "Flash": {
                            "request": {
                                "params": {
                                    "plugin": null,
                                    "controller": "Categories",
                                    "action": "index",
                                    "_ext": "json",
                                    "pass": [],
                                    "_method": "GET",
                                    "prefix": "api",
                                    "isAjax": false,
                                    "paging": {
                                        "categories": {
                                            "finder": "all",
                                            "page": 1,
                                            "current": 3,
                                            "count": 3,
                                            "perPage": 3,
                                            "prevPage": false,
                                            "nextPage": false,
                                            "pageCount": 1,
                                            "sort": null,
                                            "direction": false,
                                            "limit": null,
                                            "sortDefault": false,
                                            "directionDefault": false
                                        }
                                    }
                                },
                                "data": [],
                                "query": {
                                    "page": "2"
                                },
                                "cookies": [],
                                "url": "api/categories.json",
                                "base": "/bot/viglink/cakeviglink",
                                "webroot": "/bot/viglink/cakeviglink/",
                                "here": "/bot/viglink/cakeviglink/api/categories.json",
                                "trustProxy": false
                            },
                            "response": {},
                            "components": []
                        },
                        "Categories": {},
                        "Paginator": {
                            "request": {
                                "params": {
                                    "plugin": null,
                                    "controller": "Categories",
                                    "action": "index",
                                    "_ext": "json",
                                    "pass": [],
                                    "_method": "GET",
                                    "prefix": "api",
                                    "isAjax": false,
                                    "paging": {
                                        "categories": {
                                            "finder": "all",
                                            "page": 1,
                                            "current": 3,
                                            "count": 3,
                                            "perPage": 3,
                                            "prevPage": false,
                                            "nextPage": false,
                                            "pageCount": 1,
                                            "sort": null,
                                            "direction": false,
                                            "limit": null,
                                            "sortDefault": false,
                                            "directionDefault": false
                                        }
                                    }
                                },
                                "data": [],
                                "query": {
                                    "page": "2"
                                },
                                "cookies": [],
                                "url": "api/categories.json",
                                "base": "/bot/viglink/cakeviglink",
                                "webroot": "/bot/viglink/cakeviglink/",
                                "here": "/bot/viglink/cakeviglink/api/categories.json",
                                "trustProxy": false
                            },
                            "response": {},
                            "components": []
                        }
                    },
                    "index"
                ],
                []
            ]
        },
        {
            "file": "/var/www/html/bot/viglink/cakeviglink/vendor/cakephp/cakephp/src/Routing/Dispatcher.php",
            "line": 114,
            "function": "invokeAction",
            "class": "Cake\\Controller\\Controller",
            "type": "->",
            "args": []
        },
        {
            "file": "/var/www/html/bot/viglink/cakeviglink/vendor/cakephp/cakephp/src/Routing/Dispatcher.php",
            "line": 87,
            "function": "_invoke",
            "class": "Cake\\Routing\\Dispatcher",
            "type": "->",
            "args": [
                {
                    "components": {
                        "RequestHandler": null
                    },
                    "name": "Categories",
                    "helpers": [],
                    "request": {
                        "params": {
                            "plugin": null,
                            "controller": "Categories",
                            "action": "index",
                            "_ext": "json",
                            "pass": [],
                            "_method": "GET",
                            "prefix": "api",
                            "isAjax": false,
                            "paging": {
                                "categories": {
                                    "finder": "all",
                                    "page": 1,
                                    "current": 3,
                                    "count": 3,
                                    "perPage": 3,
                                    "prevPage": false,
                                    "nextPage": false,
                                    "pageCount": 1,
                                    "sort": null,
                                    "direction": false,
                                    "limit": null,
                                    "sortDefault": false,
                                    "directionDefault": false
                                }
                            }
                        },
                        "data": [],
                        "query": {
                            "page": "2"
                        },
                        "cookies": [],
                        "url": "api/categories.json",
                        "base": "/bot/viglink/cakeviglink",
                        "webroot": "/bot/viglink/cakeviglink/",
                        "here": "/bot/viglink/cakeviglink/api/categories.json",
                        "trustProxy": false
                    },
                    "response": {},
                    "paginate": {
                        "limit": 3
                    },
                    "autoRender": true,
                    "View": null,
                    "plugin": null,
                    "passedArgs": [],
                    "modelClass": "Categories",
                    "viewClass": null,
                    "viewVars": [],
                    "RequestHandler": {
                        "enabled": true,
                        "response": {},
                        "ext": "json",
                        "request": {
                            "params": {
                                "plugin": null,
                                "controller": "Categories",
                                "action": "index",
                                "_ext": "json",
                                "pass": [],
                                "_method": "GET",
                                "prefix": "api",
                                "isAjax": false,
                                "paging": {
                                    "categories": {
                                        "finder": "all",
                                        "page": 1,
                                        "current": 3,
                                        "count": 3,
                                        "perPage": 3,
                                        "prevPage": false,
                                        "nextPage": false,
                                        "pageCount": 1,
                                        "sort": null,
                                        "direction": false,
                                        "limit": null,
                                        "sortDefault": false,
                                        "directionDefault": false
                                    }
                                }
                            },
                            "data": [],
                            "query": {
                                "page": "2"
                            },
                            "cookies": [],
                            "url": "api/categories.json",
                            "base": "/bot/viglink/cakeviglink",
                            "webroot": "/bot/viglink/cakeviglink/",
                            "here": "/bot/viglink/cakeviglink/api/categories.json",
                            "trustProxy": false
                        },
                        "components": []
                    },
                    "Flash": {
                        "request": {
                            "params": {
                                "plugin": null,
                                "controller": "Categories",
                                "action": "index",
                                "_ext": "json",
                                "pass": [],
                                "_method": "GET",
                                "prefix": "api",
                                "isAjax": false,
                                "paging": {
                                    "categories": {
                                        "finder": "all",
                                        "page": 1,
                                        "current": 3,
                                        "count": 3,
                                        "perPage": 3,
                                        "prevPage": false,
                                        "nextPage": false,
                                        "pageCount": 1,
                                        "sort": null,
                                        "direction": false,
                                        "limit": null,
                                        "sortDefault": false,
                                        "directionDefault": false
                                    }
                                }
                            },
                            "data": [],
                            "query": {
                                "page": "2"
                            },
                            "cookies": [],
                            "url": "api/categories.json",
                            "base": "/bot/viglink/cakeviglink",
                            "webroot": "/bot/viglink/cakeviglink/",
                            "here": "/bot/viglink/cakeviglink/api/categories.json",
                            "trustProxy": false
                        },
                        "response": {},
                        "components": []
                    },
                    "Categories": {},
                    "Paginator": {
                        "request": {
                            "params": {
                                "plugin": null,
                                "controller": "Categories",
                                "action": "index",
                                "_ext": "json",
                                "pass": [],
                                "_method": "GET",
                                "prefix": "api",
                                "isAjax": false,
                                "paging": {
                                    "categories": {
                                        "finder": "all",
                                        "page": 1,
                                        "current": 3,
                                        "count": 3,
                                        "perPage": 3,
                                        "prevPage": false,
                                        "nextPage": false,
                                        "pageCount": 1,
                                        "sort": null,
                                        "direction": false,
                                        "limit": null,
                                        "sortDefault": false,
                                        "directionDefault": false
                                    }
                                }
                            },
                            "data": [],
                            "query": {
                                "page": "2"
                            },
                            "cookies": [],
                            "url": "api/categories.json",
                            "base": "/bot/viglink/cakeviglink",
                            "webroot": "/bot/viglink/cakeviglink/",
                            "here": "/bot/viglink/cakeviglink/api/categories.json",
                            "trustProxy": false
                        },
                        "response": {},
                        "components": []
                    }
                }
            ]
        },
        {
            "file": "/var/www/html/bot/viglink/cakeviglink/webroot/index.php",
            "line": 37,
            "function": "dispatch",
            "class": "Cake\\Routing\\Dispatcher",
            "type": "->",
            "args": [
                {
                    "params": {
                        "plugin": null,
                        "controller": "Categories",
                        "action": "index",
                        "_ext": "json",
                        "pass": [],
                        "_method": "GET",
                        "prefix": "api",
                        "isAjax": false,
                        "paging": {
                            "categories": {
                                "finder": "all",
                                "page": 1,
                                "current": 3,
                                "count": 3,
                                "perPage": 3,
                                "prevPage": false,
                                "nextPage": false,
                                "pageCount": 1,
                                "sort": null,
                                "direction": false,
                                "limit": null,
                                "sortDefault": false,
                                "directionDefault": false
                            }
                        }
                    },
                    "data": [],
                    "query": {
                        "page": "2"
                    },
                    "cookies": [],
                    "url": "api/categories.json",
                    "base": "/bot/viglink/cakeviglink",
                    "webroot": "/bot/viglink/cakeviglink/",
                    "here": "/bot/viglink/cakeviglink/api/categories.json",
                    "trustProxy": false
                },
                {}
            ]
        }
    ]
}
markstory commented 8 years ago

I guess my next dumb question is are there more than 1 page of results in elastic search?

gieart87 commented 8 years ago

Yes mark, I have 29 records and set limit just 3 rows. I attached a screenshot that show this elastic-search work fine when access without params (first page result). categories_oke categories

markstory commented 8 years ago

Ok. I'll take a look and try to reproduce locally.

gieart87 commented 8 years ago

haven't any update yet, @markstory ?

markstory commented 8 years ago

@gieart87 No, I've not had a chance to look at this yet.

github-actions[bot] commented 4 years ago

This issue is stale because it has been open for 120 days with no activity. Remove the stale label or comment or this will be closed in 15 days