From f751e8f66a9b6a37710d33328b5d28cd8f842405 Mon Sep 17 00:00:00 2001 From: Haydar KULEKCI Date: Sat, 21 Nov 2015 06:54:14 +0200 Subject: [PATCH] changed doSearch method as protected added some comments --- .../Query/Service/AbstractQueryService.php | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/module/Search/src/Search/Query/Service/AbstractQueryService.php b/module/Search/src/Search/Query/Service/AbstractQueryService.php index 6927ac3..fca03ff 100644 --- a/module/Search/src/Search/Query/Service/AbstractQueryService.php +++ b/module/Search/src/Search/Query/Service/AbstractQueryService.php @@ -1,6 +1,8 @@ @@ -20,6 +22,14 @@ class AbstractQueryService extends AbstractSearchService const VIEW_SHORT = 'short'; const VIEW_DETAIL = 'detail'; + /** + * Creating a Zend\Paginator\Paginator from Elastica\ResultSet. + * This paginator can be passed directly zf-hal or whereever you want. + * This method use ElasticsearchAdapter as ArrayAdapter + * + * @param ResultSet $resultSet Elastica result data + * @return Paginator Created paginator from resultset with ElasticsearchAdapter. + */ public function buildPaginator(Resultset $resultSet) { $itemsPerPage = empty($resultSet->getQuery()->getParam('size')) ? $this->getDefaultPageSize() : $resultSet->getQuery()->getParam('size'); @@ -53,9 +63,13 @@ public function buildPaginator(Resultset $resultSet) * $this->doSearch($mainQuery, 1, 10); * * @param ElasticaQuery $query + * @param int $page + * @param int $itemPerPage + * @param string $type Already defined strings at self. + * @param int $version Search version for index and type * @return Resultset */ - public function doSearch(ElasticaQuery $query, $page, $itemsPerPage, $type = self::VIEW_LIST, $version = 1) + protected function doSearch(ElasticaQuery $query, $page, $itemsPerPage, $type = self::VIEW_LIST, $version = 1) { $query->setFrom(($page - 1) * $itemsPerPage) ->setSize($itemsPerPage); @@ -74,9 +88,9 @@ public function doSearch(ElasticaQuery $query, $page, $itemsPerPage, $type = sel } return $this->getClient() - ->getIndex($this->getIndexName($version)) - ->getType($this->getTypeName($version)) - ->search($query); + ->getIndex($this->getIndexName($version)) + ->getType($this->getTypeName($version)) + ->search($query); } /**