search: first pass at removing MySQL-isms

Get rid of SQL_CALC_FOUND_ROWS and introduce @SmartFetchSize, similar
to @FetchSize but a bit smarter (@FetchSize(Integer.MIN_VALUE) doesn't work for H2 for example).

This also fixes the wrong ordering column (recordId instead of record_id)
and make the search code more generic across modules.

Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>