Skip to content

Commit

Permalink
fix(server): penalize null geodata fields when searching places (immi…
Browse files Browse the repository at this point in the history
  • Loading branch information
mertalev authored Mar 31, 2024
1 parent 6a4bc77 commit 5bc9158
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions server/src/queries/search.repository.sql
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,15 @@ WHERE
OR f_unaccent ("admin1Name") %>> f_unaccent ($1)
OR f_unaccent ("alternateNames") %>> f_unaccent ($1)
ORDER BY
COALESCE(f_unaccent (name) <->>> f_unaccent ($1), 0) + COALESCE(
COALESCE(f_unaccent (name) <->>> f_unaccent ($1), 0.1) + COALESCE(
f_unaccent ("admin2Name") <->>> f_unaccent ($1),
0
0.1
) + COALESCE(
f_unaccent ("admin1Name") <->>> f_unaccent ($1),
0
0.1
) + COALESCE(
f_unaccent ("alternateNames") <->>> f_unaccent ($1),
0
0.1
) ASC
LIMIT
20
Expand Down
8 changes: 4 additions & 4 deletions server/src/repositories/search.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ export class SearchRepository implements ISearchRepository {
.orWhere(`f_unaccent("alternateNames") %>> f_unaccent(:placeName)`)
.orderBy(
`
COALESCE(f_unaccent(name) <->>> f_unaccent(:placeName), 0) +
COALESCE(f_unaccent("admin2Name") <->>> f_unaccent(:placeName), 0) +
COALESCE(f_unaccent("admin1Name") <->>> f_unaccent(:placeName), 0) +
COALESCE(f_unaccent("alternateNames") <->>> f_unaccent(:placeName), 0)
COALESCE(f_unaccent(name) <->>> f_unaccent(:placeName), 0.1) +
COALESCE(f_unaccent("admin2Name") <->>> f_unaccent(:placeName), 0.1) +
COALESCE(f_unaccent("admin1Name") <->>> f_unaccent(:placeName), 0.1) +
COALESCE(f_unaccent("alternateNames") <->>> f_unaccent(:placeName), 0.1)
`,
)
.setParameters({ placeName })
Expand Down

0 comments on commit 5bc9158

Please sign in to comment.