仅将起始词与Rails上的PgSearch匹配

时间:2018-12-05 15:39:53

标签: ruby-on-rails ruby postgresql activerecord

我当前的范围pg_search范围如下

pg_search_scope :search_by_title, against: :original_title,
                associated_against: { movie_translations: [:title] },
                ignoring: :accents, using: { tsearch: { any_word: true, prefix: true } }

目前,只有当start_word与我的查询匹配时,我才能找到电影

Movie.create(original_title: "Bohemian Rapsody")
Movie.search_by_title("bohe")
=> [Movie id 1, original_title: "Bohemian Rapsody"]
Movie.search_by_title("Rap")
=> [Movie id 1, original_title: "Bohemian Rapsody"]

即使单词不是以我的查询开头,但我现在想返回电影

Movie.search_by_title("hemian")
=> []

0 个答案:

没有答案