aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2016-09-02 18:01:58 +0200
committerChristian Weiske <cweiske@cweiske.de>2016-09-02 18:01:58 +0200
commitc916c3e93402408fa80aee3eac5a4ba451bef115 (patch)
tree76b58c325146d83b208f46ede1c4607bfd77edb5 /src
parent9b55ca34845488c4436382844b3d1a23dbf9293c (diff)
downloadphinde-c916c3e93402408fa80aee3eac5a4ba451bef115.tar.gz
phinde-c916c3e93402408fa80aee3eac5a4ba451bef115.zip
Support multiple "nick:" terms in search field
Resolves: #17
Diffstat (limited to 'src')
-rw-r--r--src/phinde/Elasticsearch.php15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/phinde/Elasticsearch.php b/src/phinde/Elasticsearch.php
index 1732bbb..2887beb 100644
--- a/src/phinde/Elasticsearch.php
+++ b/src/phinde/Elasticsearch.php
@@ -52,13 +52,14 @@ class Elasticsearch
public function search($query, $filters, $site, $page, $perPage, $sort)
{
- if (preg_match('#nick:([^ ]*)#', $query, $matches)) {
- $authorName = $matches[1];
- $query = str_replace(
- 'nick:' . $authorName,
- 'author.name:' . $authorName,
- $query
- );
+ if (preg_match_all('#nick:([^ ]*)#', $query, $matches)) {
+ foreach ($matches[1] as $authorName) {
+ $query = str_replace(
+ 'nick:' . $authorName,
+ 'author.name:' . $authorName,
+ $query
+ );
+ }
}
$qMust = array();//query parts for the MUST section