-
-
Save Jaco-Pretorius/256fa7b75c38e346c4c3166cfa010bf1 to your computer and use it in GitHub Desktop.
associated_against - before
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT "products".* | |
FROM "products" | |
inner join | |
( | |
SELECT "products"."id" AS pg_search_id, | |
(Ts_rank((To_tsvector('simple', Coalesce("products"."name"::text, '')) | |
|| To_tsvector('simple', Coalesce(pg_search_455a24ed3ca763c7a72181.pg_search_9f77ffbdbddcb603b080a8::text, ''))), (To_tsquery('simple', ''' ' | |
|| 'QueryString' | |
|| ' ''' | |
|| ':*')), 0)) AS rank | |
FROM "products" | |
left outer join | |
( | |
SELECT "products"."id" AS id, | |
String_agg("tags"."name"::text, ' ') AS pg_search_9f77ffbdbddcb603b080a8 | |
FROM "products" | |
inner join "products_tags" | |
ON "products_tags"."product_id" = "products"."id" | |
inner join "tags" | |
ON "tags"."id" = "products_tags"."tag_id" | |
GROUP BY "products"."id") pg_search_455a24ed3ca763c7a72181 | |
ON pg_search_455a24ed3ca763c7a72181.id = "products"."id" | |
WHERE ((( | |
To_tsvector('simple', Coalesce("products"."name"::text, '')) | |
|| To_tsvector('simple', Coalesce(pg_search_455a24ed3ca763c7a72181.pg_search_9f77ffbdbddcb603b080a8::text, ''))) @@ (to_tsquery('simple', ''' ' | |
|| 'QueryString' | |
|| ' ''' | |
|| ':*'))))) AS pg_search_02b78575ff05a3f5042de1 | |
ON "products"."id" = pg_search_02b78575ff05a3f5042de1.pg_search_id | |
ORDER BY pg_search_02b78575ff05a3f5042de1.rank DESC, "products"."id" ASC limit 50 offset 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment