Upgrade to Pro — share decks privately, control downloads, hide ads and more …

論理削除と、そこでのElasticsearch活用 | 論理削除 Casual Talks #...

misoobu
August 31, 2015
20k

論理削除と、そこでのElasticsearch活用 | 論理削除 Casual Talks #1 / soft_delete

イベント: 論理削除 Casual Talks #1 : ATND https://atnd.org/events/68902
発表者: https://twitter.com/misoobu

misoobu

August 31, 2015
Tweet

Transcript

  1. ࡟আϑϥάྫ user_comments id: int user_id: int comment: text deleted_at: datetime

    ࢀর SELECT * FROM user_comments WHERE user_id = 1 AND deleted_at IS NULL; ࡟আ UPDATE user_comments SET deleted_at = NOW() WHERE id = 1;
  2. ࡟আςʔϒϧྫ ΧʔυΛച٫͢Δ user_cards id: int user_id: int card_id: int level:

    int user_card_sale_histories id: int user_id: int card_id: int level: int money: int sold_at: datetime %&-&5& */4&35
  3. &4ʹϩάΛೖΕΔ ࡟আͨ͠σʔλΛ&4ʹೖΕΔ { "user_comment_deleted_log": { "properties": { "user_id": { "type":

    "integer" }, "comment": { "type": "string" }, “deleted_at": { "type": "date" } } } } user_comments id: int user_id: int comment: text %&-&5& */4&35
  4. &4Ͱͷσʔλઃܭ { "app_log_20150831": { "mappings": { "user_comment_deleted_log": { "properties": {

    "user_id": { "type": "integer" }, "comment": { "type": "string" }, "deleted_at": { "type": "date" } } } } } } index RDBͷσʔλϕʔεΈͨ ͍ͳ΍ͭɻ ೔୯ҐͰindex͢Δɻ type RDBͷςʔϒϧ Έ͍ͨͳ΍ͭɻ छྨͰtypeΛ෼͚Δɻ JOEFYͱUZQFʢͱVTFS@JEʣΛࢦఆͯ͠ɺϩάΛऔΓग़͢ field RDBͷΧϥϜΈ͍ͨͳ ΍ͭɻ