Differential D21108 Diff 50279 src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php
Show First 20 Lines • Show All 1,795 Lines • ▼ Show 20 Lines | public function withFerretConstraint( | ||||
if (!$fulltext_tokens) { | if (!$fulltext_tokens) { | ||||
return $this; | return $this; | ||||
} | } | ||||
$this->ferretEngine = $engine; | $this->ferretEngine = $engine; | ||||
$this->ferretTokens = $fulltext_tokens; | $this->ferretTokens = $fulltext_tokens; | ||||
$current_function = $engine->getDefaultFunctionKey(); | $default_function = $engine->getDefaultFunctionKey(); | ||||
$table_map = array(); | $table_map = array(); | ||||
$idx = 1; | $idx = 1; | ||||
foreach ($this->ferretTokens as $fulltext_token) { | foreach ($this->ferretTokens as $fulltext_token) { | ||||
$raw_token = $fulltext_token->getToken(); | $raw_token = $fulltext_token->getToken(); | ||||
$function = $raw_token->getFunction(); | $function = $raw_token->getFunction(); | ||||
if ($function === null) { | if ($function === null) { | ||||
$function = $current_function; | $function = $default_function; | ||||
} | } | ||||
$raw_field = $engine->getFieldForFunction($function); | $raw_field = $engine->getFieldForFunction($function); | ||||
if (!isset($table_map[$function])) { | if (!isset($table_map[$function])) { | ||||
$alias = 'ftfield_'.$idx++; | $alias = 'ftfield_'.$idx++; | ||||
$table_map[$function] = array( | $table_map[$function] = array( | ||||
'alias' => $alias, | 'alias' => $alias, | ||||
'key' => $raw_field, | 'key' => $raw_field, | ||||
); | ); | ||||
} | } | ||||
$current_function = $function; | |||||
} | } | ||||
// Join the title field separately so we can rank results. | // Join the title field separately so we can rank results. | ||||
$table_map['rank'] = array( | $table_map['rank'] = array( | ||||
'alias' => 'ft_rank', | 'alias' => 'ft_rank', | ||||
'key' => PhabricatorSearchDocumentFieldType::FIELD_TITLE, | 'key' => PhabricatorSearchDocumentFieldType::FIELD_TITLE, | ||||
// See T13345. Not every document has a title, so we want to LEFT JOIN | // See T13345. Not every document has a title, so we want to LEFT JOIN | ||||
▲ Show 20 Lines • Show All 1,356 Lines • Show Last 20 Lines |