fix(server): penalize null geodata fields when searching places (#8408)

This commit is contained in:
Mert 2024-03-31 10:59:11 -04:00 committed by GitHub
parent 6a4bc777a2
commit 5bc9158724
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 8 deletions

View File

@ -254,15 +254,15 @@ WHERE
OR f_unaccent ("admin1Name") %>> f_unaccent ($1) OR f_unaccent ("admin1Name") %>> f_unaccent ($1)
OR f_unaccent ("alternateNames") %>> f_unaccent ($1) OR f_unaccent ("alternateNames") %>> f_unaccent ($1)
ORDER BY 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), f_unaccent ("admin2Name") <->>> f_unaccent ($1),
0 0.1
) + COALESCE( ) + COALESCE(
f_unaccent ("admin1Name") <->>> f_unaccent ($1), f_unaccent ("admin1Name") <->>> f_unaccent ($1),
0 0.1
) + COALESCE( ) + COALESCE(
f_unaccent ("alternateNames") <->>> f_unaccent ($1), f_unaccent ("alternateNames") <->>> f_unaccent ($1),
0 0.1
) ASC ) ASC
LIMIT LIMIT
20 20

View File

@ -214,10 +214,10 @@ export class SearchRepository implements ISearchRepository {
.orWhere(`f_unaccent("alternateNames") %>> f_unaccent(:placeName)`) .orWhere(`f_unaccent("alternateNames") %>> f_unaccent(:placeName)`)
.orderBy( .orderBy(
` `
COALESCE(f_unaccent(name) <->>> f_unaccent(:placeName), 0) + COALESCE(f_unaccent(name) <->>> f_unaccent(:placeName), 0.1) +
COALESCE(f_unaccent("admin2Name") <->>> f_unaccent(:placeName), 0) + COALESCE(f_unaccent("admin2Name") <->>> f_unaccent(:placeName), 0.1) +
COALESCE(f_unaccent("admin1Name") <->>> f_unaccent(:placeName), 0) + COALESCE(f_unaccent("admin1Name") <->>> f_unaccent(:placeName), 0.1) +
COALESCE(f_unaccent("alternateNames") <->>> f_unaccent(:placeName), 0) COALESCE(f_unaccent("alternateNames") <->>> f_unaccent(:placeName), 0.1)
`, `,
) )
.setParameters({ placeName }) .setParameters({ placeName })