Skip to content

Commit 4adb453

Browse files
committed
Use operator version of word_similarity because the function version doesn't use the index
1 parent 2265dea commit 4adb453

File tree

1 file changed

+3
-3
lines changed
  • src/Share/Postgres/Search/DefinitionSearch

1 file changed

+3
-3
lines changed

src/Share/Postgres/Search/DefinitionSearch/Queries.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ defNameCompletionSearch mayCaller mayFilter (Query query) limit = do
303303
SELECT br.project_id, br.release_id, br.name, br.tag
304304
FROM best_results br
305305
-- docs and tests to the bottom, but otherwise sort by the quality of the match.
306-
-- e.g. for query 'List', 'data.List' should come before 'data.List.map', and
306+
-- e.g. for query 'List', 'data.List' should come before 'data.List.map', and
307307
-- we should prioritize the correct case, e.g. 'Text' should match 'Text' before 'text'.
308308
ORDER BY br.tag <> 'doc'::definition_tag DESC, br.tag <> 'test'::definition_tag DESC,
309309
br.name LIKE ('%' || #{query} || '%') DESC,
@@ -376,8 +376,8 @@ definitionNameSearch mayCaller mayFilter limit (Query query) = do
376376
JOIN projects p ON p.id = doc.project_id
377377
JOIN project_releases r ON r.id = doc.release_id
378378
WHERE
379-
-- Adjust the similarity threshold as needed (between 0 and 1)
380-
word_similarity(#{query}, doc.name) >= 0.5
379+
-- We may wish to adjust the similarity threshold before the query.
380+
#{query} <% doc.name
381381
AND (NOT p.private OR (#{mayCaller} IS NOT NULL AND EXISTS (SELECT FROM accessible_private_projects pp WHERE pp.user_id = #{mayCaller} AND pp.project_id = p.id)))
382382
^{filters}
383383
ORDER BY doc.project_id, doc.name, r.major_version, r.minor_version, r.patch_version

0 commit comments

Comments
 (0)