Open smoothdvd opened 6 years ago
Running in a similar issue here
add a monkey path to remove space in SQL
module PgSearch
module Features
class TSearch
def tsquery_expression(term_sql, negated:, prefix:)
terms = [
(Arel::Nodes.build_quoted('!') if negated),
# Arel::Nodes.build_quoted("' "), # comment this line to remove space
term_sql,
# Arel::Nodes.build_quoted(" '"), # comment this line to remove space
(Arel::Nodes.build_quoted(":*") if prefix)
].compact
terms.inject do |memo, term|
Arel::Nodes::InfixOperation.new("||", memo, Arel::Nodes.build_quoted(term))
end
end
end
end
end
Search result always return empty when I use full text search with Chinese language. PostgreSQL version is 10.5 My pg_search_scope is defined as:
Generated SQL:
Notification Load (1.3ms) SELECT "notifications".* FROM "notifications" INNER JOIN (SELECT "notifications"."id" AS pg_search_id, (ts_rank((to_tsvector('jiebacfg', coalesce("notifications"."title"::text, ''))), (to_tsquery('jiebacfg', ''' ' || '大于' || ' ''')), 0)) AS rank FROM "notifications" WHERE (((to_tsvector('jiebacfg', coalesce("notifications"."title"::text, ''))) @@ (to_tsquery('jiebacfg', ''' ' || '大于' || ' '''))))) AS pg_search_8bb6922758ad870f844ad0 ON "notifications"."id" = pg_search_8bb6922758ad870f844ad0.pg_search_id ORDER BY "notifications"."id"DESC, pg_search_8bb6922758ad870f844ad0.rank DESC, "notifications"."id" ASC
If I change ''' ' || '大于' || ' ''' to '大于' and execute the sql in PostgreSQL console, it will return correct result.