Я новичок в Postgresql, работающем с PG 9.6, и вот пример запроса:
select * from (select "posts".* from "posts" inner join "feeds" on posts.destination_feed_ids # feeds.id > 0 and feeds.name='Posts' inner join "users" on feeds.user_id=users.uid and not users.is_private where to_tsvector('pg_catalog.russian', posts.body) @@ to_tsquery('pg_catalog.russian', 'xxx') union select "posts".* from "posts" inner join "feeds" on posts.destination_feed_ids # feeds.id > 0 and feeds.name='Posts' inner join "users" on feeds.user_id=users.uid and not users.is_private where
posts.uid in (
select post_id from comments where to_tsvector('pg_catalog.russian', comments.body) @@ to_tsquery('pg_catalog.russian', 'xxx')
) union select "posts".* from "posts" where "posts"."user_id" = '48d85d83-b562-439f-addf-d75cd75d092f' and to_tsvector('pg_catalog.russian', posts.body) @@ to_tsquery('pg_catalog.russian', 'xxx') union select "posts".* from "posts" where "posts"."user_id" = '48d85d83-b562-439f-addf-d75cd75d092f' and
posts.uid in (
select post_id from comments where to_tsvector('pg_catalog.russian', comments.body) @@ to_tsquery('pg_catalog.russian', 'xxx')
) union select "posts".* from "posts" inner join "feeds" on posts.destination_feed_ids # feeds.id > 0 and feeds.name='Posts' inner join "users" on feeds.user_id=users.uid and users.is_private=true where to_tsvector('pg_catalog.russian', posts.body) @@ to_tsquery('pg_catalog.russian', 'xxx') and "feeds"."id" in (5,10,11,12,15,16,17) union select "posts".* from "posts" inner join "feeds" on posts.destination_feed_ids # feeds.id > 0 and feeds.name='Posts' inner join "users" on feeds.user_id=users.uid and users.is_private=true where
posts.uid in (
select post_id from comments where to_tsvector('pg_catalog.russian', comments.body) @@ to_tsquery('pg_catalog.russian', 'xxx')
)
and "feeds"."id" in (5,10,11,12,15,16,17) ) as found_posts order by found_posts.bumped_at desc offset 0 limit 31
Как вы можете видеть, есть пара pg_catalog.russian
, которые я не понимаю, их роль в запросе. В настоящее время запрос не возвращает результатов для результатов «no-ascii».
Запрос ограничен с помощью файла конфигурации knex, который имеет:
textSearchConfigName: 'pg_catalog.russian'
в нем.
Я хочу изменить запрос (или базу данных?), Чтобы он мог запрашивать все строки utf8.