HomePhabricator

Select Ferret fulltext columns in results so fulltext queries work under UNION

Description

Select Ferret fulltext columns in results so fulltext queries work under UNION

Summary:
Ref T13091. In Differential, if you provide a query and "Sort by: Relevance", we build a query like this:

((SELECT revision.* FROM ... ORDER BY rank) UNION ALL (SELECT revision.* FROM ... ORDER BY rank)) ORDER BY rank

The internal "ORDER BY rank" is technically redundant (probably?), but doesn't hurt anything, and makes construction easier.

The problem is that the outer "ORDER BY rank" at the end, which attempts to order the results of the two parts of the UNION, can't actually order them, since rank wasn't selected.

(The column isn't actually "rank", which is selected -- it's the document modified/created subcolumns, which are not.)

To fix this, actually select the fulltext columns into the result set.

Test Plan:

  • Ran a non-empty fulltext query in Differential with "Bucket: Required Action" selected so the UNION construction fired.
  • Ran normal queries in Maniphest and global search.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13091

Differential Revision: https://secure.phabricator.com/D20297