Differential D20660 Diff 49286 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,819 Lines • ▼ Show 20 Lines | foreach ($this->ferretTokens as $fulltext_token) { | ||||
$current_function = $function; | $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 | |||||
// this table to avoid excluding documents with no title that match | |||||
// the query in other fields. | |||||
'optional' => true, | |||||
); | ); | ||||
$this->ferretTables = $table_map; | $this->ferretTables = $table_map; | ||||
return $this; | return $this; | ||||
} | } | ||||
protected function buildFerretSelectClause(AphrontDatabaseConnection $conn) { | protected function buildFerretSelectClause(AphrontDatabaseConnection $conn) { | ||||
▲ Show 20 Lines • Show All 262 Lines • ▼ Show 20 Lines | foreach ($flat as $spec) { | ||||
$alias, | $alias, | ||||
$alias, | $alias, | ||||
$ngram); | $ngram); | ||||
} | } | ||||
foreach ($this->ferretTables as $table) { | foreach ($this->ferretTables as $table) { | ||||
$alias = $table['alias']; | $alias = $table['alias']; | ||||
if (empty($table['optional'])) { | |||||
$join_type = qsprintf($conn, 'JOIN'); | |||||
} else { | |||||
$join_type = qsprintf($conn, 'LEFT JOIN'); | |||||
} | |||||
$joins[] = qsprintf( | $joins[] = qsprintf( | ||||
$conn, | $conn, | ||||
'JOIN %T %T ON ft_doc.id = %T.documentID | '%Q %T %T ON ft_doc.id = %T.documentID | ||||
AND %T.fieldKey = %s', | AND %T.fieldKey = %s', | ||||
$join_type, | |||||
$field_table, | $field_table, | ||||
$alias, | $alias, | ||||
$alias, | $alias, | ||||
$alias, | $alias, | ||||
$table['key']); | $table['key']); | ||||
} | } | ||||
return $joins; | return $joins; | ||||
▲ Show 20 Lines • Show All 1,056 Lines • Show Last 20 Lines |