Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions internal/ogc/features/datasources/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,21 +431,21 @@ func makeSearchQuery(index string, bboxFilter string, axisOrder d.AxisOrder) str
FROM
results r
WHERE
-- less then rank threshold results don't need to be pre-ranked, they can be ranked based on score
-- less than rank-threshold results don't need to be pre-ranked, they can be ranked based on score
CASE WHEN (SELECT c from results_count) < @rt THEN 1 = 1 END
) UNION ALL (
SELECT
*
FROM
results r
WHERE
-- pre-rank more then rank threshold results by ordering on suggest length and display_name
CASE WHEN (SELECT c from results_count) = @rt THEN 1 = 1 END AND
array_length(string_to_array(r.suggest, ' '), 1) <= @prwcc
-- pre-rank more than rank-threshold results by ordering on suggest length and display_name
CASE WHEN (SELECT c from results_count) >= @rt THEN 1 = 1 END
ORDER BY
array_length(string_to_array(r.suggest, ' '), 1) ASC,
-- order by the number of words in the suggest string, up to the limit given in @prwcc
(SELECT COUNT(*) FROM unnest(regexp_split_to_array(r.suggest, '\s+')) AS words LIMIT @prwcc) ASC,
r.display_name COLLATE "custom_numeric" ASC
LIMIT (@lm::int * @prlm::int) -- return limited pre-ranked results for ranking based on scor
LIMIT (@lm::int * @prlm::int) -- return limited pre-ranked results for ranking based on score
)
) u
LEFT JOIN
Expand Down