diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2016-08-30 07:36:34 +0200 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2016-08-30 07:36:34 +0200 |
| commit | 210a7ec82c46ed6e410f80be4b1149f5295b1306 (patch) | |
| tree | 0690e20cb8cb48d4ad33927616e49b62c4b33dc2 | |
| parent | 686f1cec3fd35782c30d20f891fec2f434e5d02f (diff) | |
| download | phinde-210a7ec82c46ed6e410f80be4b1149f5295b1306.tar.gz phinde-210a7ec82c46ed6e410f80be4b1149f5295b1306.zip | |
Support "nick:cweiske" search syntax as alias for "author.name"
Resolves: #3
| -rw-r--r-- | src/phinde/Elasticsearch.php | 9 |
1 files changed, 9 insertions, 0 deletions
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 { |
