Railsで組み込みのPostgresQL全文検索を使用する場合は、Ryan Batesのexcellent tutorialをフォローしています。私は現在、pg_search gem un-indexedを問題なく使用していますが、パフォーマンスを向上させる必要があります。私は "英語"辞書を指定したtsvectorを使用しています。私はライアンの指示に従ってPostgreSQLのバージョン9.1.4rake dbを実行できません:Railscastサンプルを使用して、RailsでPostgreSQLのtsvector GINインデックスを移行してください
を使用してい
は、私が作成したい二つの新しいインデックスを指定して、このコードで新しい移行を実行しています。ここで最初のスキーマは次のとおりです。
create_table "references", :force => true do |t|
t.string "title"
t.string "type"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "public_url"
t.string "content_type"
t.integer "file_size"
t.text "overview"
t.text "body"
t.text "full_text"
t.integer "folder_id"
end
私の移行は次のようになります。
def up
execute "create index references_title on references using gin(to_tsvector('english', title))"
execute "create index references_full_text on references using gin(to_tsvector('english', full_text))"
end
def down
execute "drop index references_title"
execute "drop index references_full_text"
end
は、私も先に行ってとコメント解除している:私は続けるapplication.rb
config.active_record.schema_format = :sql
でSQLオプションを同じレイクを打ち切るエラー:
== AddSearchIndexesToReferences: migrating ===================================
-- execute("CREATE INDEX references_title on references using gin(to_tsvector('english', title))")
rake aborted!
An error has occurred, this and all later migrations canceled:
PG::Error: ERROR: syntax error at or near "references"
LINE 1: CREATE INDEX references_title on references using gin(to_tsv...
^
: CREATE INDEX references_title on references using gin(to_tsvector('english', title))