fix canonicalization and show only active children in form

This commit is contained in:
2021-10-08 11:30:35 +02:00
parent 58ddbfb67b
commit 9a708ca618
6 changed files with 113 additions and 32 deletions

View File

@@ -20,9 +20,14 @@ class ThirdPartyApiSearch implements SearchApiInterface
return (new SearchApiQuery)
->setSelectKey('tparty')
->setSelectJsonbMetadata("jsonb_build_object('id', tparty.id)")
->setSelectPertinence("SIMILARITY(?, LOWER(UNACCENT(tparty.name)))", [ $pattern ])
->setSelectPertinence("GREATEST(".
"STRICT_WORD_SIMILARITY(LOWER(UNACCENT(?)), tparty.canonicalized),".
"(tparty.canonicalized LIKE '%' || LOWER(UNACCENT(?)) || '%')::int".
")", [ $pattern, $pattern ])
->setFromClause('chill_3party.third_party AS tparty')
->setWhereClause('SIMILARITY(LOWER(UNACCENT(?)), LOWER(UNACCENT(tparty.name))) > 0.20', [ $pattern ])
->setWhereClause("tparty.active IS TRUE ".
"AND (LOWER(UNACCENT(?)) <<% tparty.canonicalized OR ".
"tparty.canonicalized LIKE '%' || LOWER(UNACCENT(?)) || '%')", [ $pattern, $pattern ])
;
}
@@ -33,7 +38,7 @@ class ThirdPartyApiSearch implements SearchApiInterface
public function prepare(array $metadatas): void
{
}
public function supportsResult(string $key, array $metadatas): bool