fix(SearchDoc): Change getOriginalQuery() to return complete SQL query (refs #4787)

getOriginalQuery() returns a SQL fragment corresponding to the query that would
be performed by the SearchDoc.

The SQL fragment contains the SELECT part without the "ORDER BY ..." part and
without the trailing semi-colon.
test(SearchDoc): Add PU test for getOriginalQuery() (refs #4787)
Merge pull request #1178 from eguaj/3.2-A4787

fix(SearchDoc): Change getOriginalQuery() to return complete SQL query (closes #4787)