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
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2018-06-13 21:10:39 +0300
committerMaxence Lange <maxence@artificial-owl.com>2018-06-13 21:10:39 +0300
commitbdef408c1f6ddbef80827fae36aa933a036f819c (patch)
treefb227266357af265106f9f9d0e9242b5e191b8a3
parent9ebf950aec300a955ea74e31031372e63ddf34e4 (diff)
limit field with in:v0.8.0
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
-rw-r--r--lib/Model/SearchRequest.php48
1 files changed, 47 insertions, 1 deletions
diff --git a/lib/Model/SearchRequest.php b/lib/Model/SearchRequest.php
index eec7d32..5afb2db 100644
--- a/lib/Model/SearchRequest.php
+++ b/lib/Model/SearchRequest.php
@@ -58,6 +58,9 @@ class SearchRequest implements \JsonSerializable {
private $fields = [];
/** @var array */
+ private $limitFields = [];
+
+ /** @var array */
private $wildcardFields = [];
/** @var array */
@@ -157,14 +160,21 @@ class SearchRequest implements \JsonSerializable {
}
list($kw, $value) = explode(':', $word, 2);
- $options = ['is', 'show'];
+ $options = ['is', 'show'];
if (in_array($kw, $options)) {
$this->addOption($kw . '_' . $value, '1');
return true;
}
+ $valuedOptions = ['in'];
+ if (in_array($kw, $valuedOptions)) {
+ $this->addMultipleOption($kw, $value);
+
+ return true;
+ }
+
return false;
}
@@ -230,6 +240,22 @@ class SearchRequest implements \JsonSerializable {
}
/**
+ * @param $key
+ * @param $value
+ *
+ * @return $this
+ */
+ public function addMultipleOption($key, $value) {
+ if (!array_key_exists($key, $this->options)) {
+ $this->options[$key] = [];
+ }
+
+ $this->options[$key][] = $value;
+
+ return $this;
+ }
+
+ /**
* @param string $option
*
* @return mixed|string
@@ -280,6 +306,26 @@ class SearchRequest implements \JsonSerializable {
return $this;
}
+
+ /**
+ * @param $field
+ *
+ * @return $this
+ */
+ public function limitToField($field) {
+ array_push($this->limitFields, $field);
+
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function getLimitFields() {
+ return $this->limitFields;
+ }
+
+
/**
* @param $field
*