mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-09 16:32:39 +01:00
Update Phabricator to use intermediate tokens from the query compiler
Summary: Depends on D17669. Ref T12137. Ref T12003. Ref T2632. Ref T7860. Converts Phabricator to the new parse + compile workflow with intermediate tokens. Also fixes a bug where searches for `cat"` or similar (unmatched quotes) wouldn't produce a nice exception. Test Plan: - Fulltext searched. - Fulltext searched in Conpherence. - Fulltext searched with bad syntax. Reviewers: chad Reviewed By: chad Maniphest Tasks: T12137, T12003, T7860, T2632 Differential Revision: https://secure.phabricator.com/D17670
This commit is contained in:
parent
4bf968148c
commit
cb49acc2ca
3 changed files with 11 additions and 6 deletions
|
@ -56,9 +56,9 @@ final class ConpherenceFulltextQuery
|
|||
}
|
||||
|
||||
if (strlen($this->fulltext)) {
|
||||
$compiled_query = PhabricatorSearchDocument::newQueryCompiler()
|
||||
->setQuery($this->fulltext)
|
||||
->compileQuery();
|
||||
$compiler = PhabricatorSearchDocument::newQueryCompiler();
|
||||
$tokens = $compiler->newTokens($this->fulltext);
|
||||
$compiled_query = $compiler->compileQuery($tokens);
|
||||
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
|
|
|
@ -398,12 +398,13 @@ final class PhabricatorMySQLFulltextStorageEngine
|
|||
$stemmer = new PhutilSearchStemmer();
|
||||
|
||||
$compiler = PhabricatorSearchDocument::newQueryCompiler()
|
||||
->setQuery($raw_query)
|
||||
->setStemmer($stemmer);
|
||||
|
||||
$tokens = $compiler->newTokens($raw_query);
|
||||
|
||||
$queries = array();
|
||||
$queries[] = $compiler->compileLiteralQuery();
|
||||
$queries[] = $compiler->compileStemmedQuery();
|
||||
$queries[] = $compiler->compileLiteralQuery($tokens);
|
||||
$queries[] = $compiler->compileStemmedQuery($tokens);
|
||||
|
||||
return implode(' ', array_filter($queries));
|
||||
}
|
||||
|
|
|
@ -253,6 +253,10 @@ class PhabricatorSearchService
|
|||
$res = $engine->executeSearch($query);
|
||||
// return immediately if we get results
|
||||
return $res;
|
||||
} catch (PhutilSearchQueryCompilerSyntaxException $ex) {
|
||||
// If there's a query compilation error, return it directly to the
|
||||
// user: they issued a query with bad syntax.
|
||||
throw $ex;
|
||||
} catch (Exception $ex) {
|
||||
$exceptions[] = $ex;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue