From 39b74572e6f73cee600c1af71f104aec90577a0c Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 11 Sep 2017 16:35:09 -0700 Subject: [PATCH] Return fulltext tokens from the Ferret fulltext engine Summary: Ref T12819. These render the little "Searched For: X, Y, U V" hint about how something was parsed. (This might get a "substring" color or "title only" color or something in the future.) Test Plan: {F5178807} Reviewers: chad Reviewed By: chad Maniphest Tasks: T12819 Differential Revision: https://secure.phabricator.com/D18589 --- .../PhabricatorFerretFulltextStorageEngine.php | 4 ++++ .../policy/PhabricatorCursorPagedPolicyAwareQuery.php | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/applications/search/fulltextstorage/PhabricatorFerretFulltextStorageEngine.php b/src/applications/search/fulltextstorage/PhabricatorFerretFulltextStorageEngine.php index 74e8771de7..b3618db5ff 100644 --- a/src/applications/search/fulltextstorage/PhabricatorFerretFulltextStorageEngine.php +++ b/src/applications/search/fulltextstorage/PhabricatorFerretFulltextStorageEngine.php @@ -86,6 +86,10 @@ final class PhabricatorFerretFulltextStorageEngine $type_results[$type] = $results; $metadata += $engine_query->getFerretMetadata(); + + if (!$this->fulltextTokens) { + $this->fulltextTokens = $engine_query->getFerretTokens(); + } } $list = array(); diff --git a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php index 0488ba6133..5cacd66d06 100644 --- a/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php +++ b/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php @@ -1469,6 +1469,17 @@ abstract class PhabricatorCursorPagedPolicyAwareQuery return $this; } + public function getFerretTokens() { + if (!$this->supportsFerretEngine()) { + throw new Exception( + pht( + 'Query ("%s") does not support the Ferret fulltext engine.', + get_class($this))); + } + + return $this->ferretTokens; + } + public function withFerretConstraint( PhabricatorFerretEngine $engine, array $fulltext_tokens) {