how to implement pagination using PHPSolr Client?

342 views
Skip to first unread message

Gunasekhar T

unread,
May 10, 2014, 5:48:18 AM5/10/14
to php-sol...@googlegroups.com
Hi,

I am trying to build a search application using PHP Solr Client. However I could not find any classes in the client library to implement pagination of search results. Can someone help me with a sample paging code in Php?

Cheers
Guna

Donovan Jimenez

unread,
May 10, 2014, 9:02:14 PM5/10/14
to php-sol...@googlegroups.com
offset and limit in the search function controls pagination


/**
* Simple Search interface
*
* @param string $query The raw query string
* @param int $offset The starting offset for result documents
* @param int $limit The maximum number of result documents to return
* @param array $params key / value pairs for other query parameters (see Solr documentation), use arrays for parameter keys used more than once (e.g. facet.field)
* @param string $method The HTTP method (Apache_Solr_Service::METHOD_GET or Apache_Solr_Service::METHOD::POST)
* @return Apache_Solr_Response
*
* @throws Apache_Solr_HttpTransportException If an error occurs during the service call
* @throws Apache_Solr_InvalidArgumentException If an invalid HTTP method is used
*/
public function search($query, $offset = 0, $limit = 10, $params = array(), $method = self::METHOD_GET)



--
You received this message because you are subscribed to the Google Groups "PHP Solr Client" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-solr-clie...@googlegroups.com.
To post to this group, send email to php-sol...@googlegroups.com.
Visit this group at http://groups.google.com/group/php-solr-client.
For more options, visit https://groups.google.com/d/optout.

Cliff Ingham

unread,
May 12, 2014, 8:08:39 AM5/12/14
to php-sol...@googlegroups.com
I don't know how complex of a system you're working on.  However; by the time you start using Solr for search, you might be reaching a point where a framework could be useful.

I use ZendFramework 2's Pagination class.  It has worked very well for my projects.  For Solr, you'll need to write a small Adapter for Solr response objects to be paginated.

Aside from the Solr paginator adapter, I use a single Search class that encapsulates all the interaction my application does with Solr.

Here's an example from our Media Manager application
https://github.com/City-of-Bloomington/media-manager/blob/master/Models/Search.php
https://github.com/City-of-Bloomington/media-manager/blob/master/libraries/Blossom/Classes/SolrPaginatorAdapter.php
Reply all
Reply to author
Forward
0 new messages