简体   繁体   中英

Update index to be a gin index

In my rails app I have table with indexes that looks like this:

  create_table "people", force: :cascade do |t|
    t.datetime "created_at",  null: false
    t.datetime "updated_at",  null: false
    t.string   "first_name",  limit: 255
    t.string   "last_name",   limit: 255
    t.string   "middle_name", limit: 255

    t.index name: "people_lowercase_full_names_gist_ops_idx", using: :gist, expression: "lower((((COALESCE(first_name, ''::character varying))::text || (COALESCE(middle_name, ''::character varying))::text) || (COALESCE(last_name, ''::character varying))::text))"
    t.index name: "people_lowercase_full_names_text_pattern_ops_idx", expression: "lower((((COALESCE(first_name, ''::character varying))::text || (COALESCE(middle_name, ''::character varying))::text) || (COALESCE(last_name, ''::character varying))::text))"
  end

How can I update those indexes to be a gin indexes?

you cannot change the index type. changing the index type can only be done by drop / create. it requires a total rebuild. this will never be possible actually.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM