thirdparty search: adapt pertinence select clause for searching into children

This commit is contained in:
nobohan 2022-02-15 13:39:46 +01:00
parent bc99c85802
commit f5bc8dca5e

View File

@ -93,12 +93,18 @@ class ThirdPartyApiSearch implements SearchApiInterface
parent.canonicalized LIKE '%' || LOWER(UNACCENT(?)) || '%')
";
$whereArgs[] = [$str, $str, $str, $str];
$pertinence[] = 'STRICT_WORD_SIMILARITY(LOWER(UNACCENT(?)), tparty.canonicalized) + ' .
"(tparty.canonicalized LIKE '%s' || LOWER(UNACCENT(?)) || '%')::int + " .
$pertinence[] = "GREATEST(
STRICT_WORD_SIMILARITY(LOWER(UNACCENT(?)), tparty.canonicalized),
STRICT_WORD_SIMILARITY(LOWER(UNACCENT(?)), parent.canonicalized)
) + " .
"GREATEST(
(tparty.canonicalized LIKE '%s' || LOWER(UNACCENT(?)) || '%')::int,
(parent.canonicalized LIKE '%s' || LOWER(UNACCENT(?)) || '%')::int
) + " .
// take postcode label into account, but lower than the canonicalized field
"COALESCE((LOWER(UNACCENT(cmpc.label)) LIKE '%' || LOWER(UNACCENT(?)) || '%')::int * 0.3, 0) + " .
"COALESCE((LOWER(UNACCENT(cmpc_p.label)) LIKE '%' || LOWER(UNACCENT(?)) || '%')::int * 0.3, 0)";
$pertinenceArgs[] = [$str, $str, $str, $str];
$pertinenceArgs[] = [$str, $str, $str, $str, $str, $str];
}
}