Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/fulltextsearch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/Model
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2018-01-04 00:52:32 +0300
committerMaxence Lange <maxence@artificial-owl.com>2018-01-04 00:52:32 +0300
commit0011b18483cebbf2582d6e77a1ac51c79810f523 (patch)
tree2bda1d0b06df7ae403e6c1240219afae141fa3df /lib/Model
parent3d1e05120d8cb382a1719a120591521eb6b7db82 (diff)
navigation
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib/Model')
-rw-r--r--lib/Model/SearchRequest.php8
-rw-r--r--lib/Model/SearchResult.php22
2 files changed, 27 insertions, 3 deletions
diff --git a/lib/Model/SearchRequest.php b/lib/Model/SearchRequest.php
index 37ebce1..776ee88 100644
--- a/lib/Model/SearchRequest.php
+++ b/lib/Model/SearchRequest.php
@@ -34,7 +34,7 @@ class SearchRequest implements \JsonSerializable {
private $search;
/** @var int */
- private $page = 0;
+ private $page = 1;
/** @var int */
private $size = 10;
@@ -77,6 +77,10 @@ class SearchRequest implements \JsonSerializable {
* @param int $page
*/
public function setPage($page) {
+ if ($page < 1) {
+ $page = 1;
+ }
+
$this->page = $page;
}
@@ -103,7 +107,7 @@ class SearchRequest implements \JsonSerializable {
return [
'search' => $this->getSearch(),
'page' => $this->getPage(),
- 'size' => $this->getSize()
+ 'size' => $this->getSize()
];
}
diff --git a/lib/Model/SearchResult.php b/lib/Model/SearchResult.php
index 830c423..d6e32d0 100644
--- a/lib/Model/SearchResult.php
+++ b/lib/Model/SearchResult.php
@@ -52,6 +52,9 @@ class SearchResult implements \JsonSerializable {
/** @var boolean */
private $timedOut;
+ /** @var SearchRequest */
+ private $request;
+
public function __construct() {
}
@@ -185,6 +188,21 @@ class SearchResult implements \JsonSerializable {
/**
+ * @return SearchRequest
+ */
+ public function getRequest() {
+ return $this->request;
+ }
+
+ /**
+ * @param SearchRequest $request
+ */
+ public function setRequest($request) {
+ $this->request = $request;
+ }
+
+
+ /**
* @return array<string,array<string,string>|IndexDocument[]|integer>
*/
public function jsonSerialize() {
@@ -201,9 +219,11 @@ class SearchResult implements \JsonSerializable {
[
'timedOut' => $this->isTimedOut(),
'time' => $this->getTime(),
+ 'maxPage' => ceil($this->getTotal() / $this->getSize()),
'size' => $this->getSize(),
'total' => $this->getTotal(),
- 'maxScore' => $this->getMaxScore()
+ 'maxScore' => $this->getMaxScore(),
+ 'request' => $this->getRequest()
]
];
}