cakephp elastic-search pagination


/ Published in: PHP
Save to your folder(s)

How do you use the elastic-search plugin with cake's native pagination?


Copy this code and paste it in your HTML
  1. $products = $this->Product->find('all', array(
  2. 'fields' => array('id'),
  3. 'conditions' => array('title in' => explode(" ", $query))
  4. )->toArray();
  5.  
  6. $ids = array();
  7. foreach ($products as $product) {
  8. $ids[] = $product['id'];
  9. }
  10.  
  11. $this->paginate = [
  12. 'limit' => 10,
  13. 'conditions' => array(
  14. 'id IN' => array_unique($ids) //to eliminate duplicate ids
  15. ),
  16. ];
  17.  
  18. $products = $this->paginate('Products');
  19. $this->set('products', $products');

URL: http://aerocoding.com/en/question/27/Using-cakephp-elastic-search-with-pagination

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.