Support "nick:cweiske" search syntax as alias for "author.name"
authorChristian Weiske <cweiske@cweiske.de>
Tue, 30 Aug 2016 05:36:34 +0000 (07:36 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 30 Aug 2016 05:36:34 +0000 (07:36 +0200)
Resolves: #3

src/phinde/Elasticsearch.php

index 310b63b..96a769b 100644 (file)
@@ -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 {