Skip to content

Commit ce0766f

Browse files
committed
[MODEL] Updated the chapter on "Pagination" in the README
1 parent 2959243 commit ce0766f

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Diff for: elasticsearch-model/LICENSE.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2013 Elasticsearch
1+
Copyright (c) 2014 Elasticsearch
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

Diff for: elasticsearch-model/README.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ response.records.each_with_hit { |record, hit| puts "* #{record.title}: #{hit._s
246246
#### Pagination
247247

248248
You can implement pagination with the `from` and `size` search parameters. However, search results
249-
can be automatically paginated with the [Kaminari](https://github.com/amatsuda/kaminari) gem.
249+
can be automatically paginated with the [`kaminari`](http://rubygems.org/gems/kaminari) gem.
250250

251251
If Kaminari is loaded, use the familiar paging methods:
252252

@@ -259,6 +259,17 @@ In a Rails controller, use the the `params[:page]` parameter to paginate through
259259

260260
```ruby
261261
@articles = Article.search(params[:q]).page(params[:page]).records
262+
263+
@articles.current_page
264+
# => 2
265+
@articles.next_page
266+
# => 3
267+
```
268+
To initialize and include the pagination support manually:
269+
270+
```ruby
271+
Kaminari::Hooks.init
272+
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
262273
```
263274

264275
#### The Elasticsearch DSL
@@ -640,7 +651,7 @@ module and its submodules for technical information.
640651

641652
This software is licensed under the Apache 2 license, quoted below.
642653

643-
Copyright (c) 2013 Elasticsearch <http://www.elasticsearch.org>
654+
Copyright (c) 2014 Elasticsearch <http://www.elasticsearch.org>
644655

645656
Licensed under the Apache License, Version 2.0 (the "License");
646657
you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)