doujiao3346 2019-08-06 08:54
浏览 107
已采纳

如何使用这种架构在Elastic Search中复制索引?

I have a scenario where I have to import data (millions of records) from multiple sources and save it in a database. A user should get results in under 2-3 seconds when they try to search for any information related to that data.

For this, I designed an architecture where I used golang to import data from multiple sources and pushed data in AWS SQS. I've created a lambda function which triggers when AWS SQS has some data. This lambda function then pushes data in AWS Elastic Search. I've created a Rest API using which I give results to the user.

I use CRON to do this importing work every morning. Now my problem is if a new batch of data comes I want to delete the existing data and replace all of them with the new data. I'm stuck at how I can achieve this deleting and adding new data part.

I thought of creating a temporary index and then replacing it with the original index. But the problem is I do not know when importing has ended and can make this index switch.

  • 写回答

1条回答 默认 最新

  • duanhe7471 2019-08-16 14:06
    关注

    The concept you're after is an index alias. The basic workflow would be:

    1. Import today's data into an index with my-index-2019-09-16 (for example).
    2. Make sure the import is complete and worked correctly.
    3. Point the alias to the new index (it's an atomic switch between the indices):

      POST /_aliases
      {
          "actions" : [
              { "remove" : { "index" : "my-index-2019-09-15", "alias" : "my-index" } },
              { "add" : { "index" : "my-index-2019-09-16", "alias" : "my-index" } }
          ]
      }
      
    4. Delete the old index.

    You will double the disk space during the import process, but otherwise this should work without any issues and you only delete data once it has a proper replacement.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题