-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changed doSearch method as protected
added some comments
- Loading branch information
Showing
1 changed file
with
18 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
<?php | ||
/** | ||
* Abstract Search Service | ||
* You can use this abstract class create a QueryServices. | ||
* This query services search your datas on Elasticsearch. | ||
* | ||
* @since Oct 2015 | ||
* @author Haydar KULEKCI <[email protected]> | ||
|
@@ -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); | ||
} | ||
|
||
/** | ||
|