From: Christian Weiske Date: Tue, 30 Aug 2016 05:36:34 +0000 (+0200) Subject: Support "nick:cweiske" search syntax as alias for "author.name" X-Git-Tag: v0.2.0~35 X-Git-Url: https://git.cweiske.de/phinde.git/commitdiff_plain/210a7ec82c46ed6e410f80be4b1149f5295b1306?ds=sidebyside Support "nick:cweiske" search syntax as alias for "author.name" Resolves: #3 --- diff --git a/src/phinde/Elasticsearch.php b/src/phinde/Elasticsearch.php index 310b63b..96a769b 100644 --- a/src/phinde/Elasticsearch.php +++ b/src/phinde/Elasticsearch.php @@ -70,6 +70,15 @@ 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 ($sort == 'date') { $sortCfg = array('modate' => array('order' => 'desc')); } else {