# Elastic Search Sorting, All Documents and Pagination

If you have viewed the php docs for elastic search https://github.com/elasticsearch/elasticsearch-php/tree/v1.3.2

You note they don’t talk about a lot of really basic operations. After some trial and error I have come across some of those mentioned above.

### Pagination

```\$searchParams['body']['from'] = \$request->current_page*\$request->per_page;
\$searchParams['body']['size'] = \$request->per_page;```

### All Documents Queury

```\$searchParams['body']['from'] = \$request->current_page*\$request->per_page;
\$searchParams['body']['size'] = \$request->per_page;
\$searchParams['body']['query']['match_all']=[];```

### Sorting Results

```\$searchParams['body']['sort']['id']='desc';
\$searchParams['body']['from'] = \$request->current_page*\$request->per_page;
\$searchParams['body']['size'] = \$request->per_page;
\$searchParams['body']['query']['match_all']=[];```

Happy searching.

API Engineer