简体   繁体   English

elasticsearch 中频繁更新的影响

[英]Impact of frequent updates in elasticsearch

We are planning to use elasticsearch to store merchant profile details and summary of his transaction amount.我们计划使用 elasticsearch 来存储商家资料详细信息和他的交易金额摘要。 We have to update document for every transactions to maintain the total amount in sync.我们必须更新每笔交易的文件以保持总金额同步。

  1. Is it ok to update document frequently to increment a field?是否可以频繁更新文档以增加字段?
  2. We are planning to use update API to update a filed, Will it reindex the whole document?我们计划使用更新 API 来更新一个文件,它会重新索引整个文档吗? Is there any option to update only specific field without reindexing other fields?是否有任何选项可以仅更新特定字段而不重新索引其他字段?
  3. It will be good if we have two index or a index with two types, one for profile other for summary?如果我们有两个索引或一个具有两种类型的索引会很好,一种用于概要文件,另一种用于摘要?

Thanks in advance.提前致谢。

Please find the answers inline:请在线查找答案:

  1. Is it ok to update documents frequently to increment a field?是否可以频繁更新文档以增加字段?

It's very subjective and based on various parameters like how many documents in your index, how many shards, how many data nodes and what is your write QPS etc, Elasticsearch is very scalable and if you tune your cluster and index, you can get very high throughput without any issues.这是非常主观的,并且基于各种参数,例如索引中有多少文档、多少分片、多少数据节点以及您的写入 QPS 等,Elasticsearch 非常可扩展,如果您调整集群和索引,您可以获得非常高的吞吐量没有任何问题。 If you provide more details, we can suggest how to tweak this for a write-heavy system like yours.如果您提供更多详细信息,我们可以建议如何针对像您这样的写入繁重的系统进行调整。 Please refer ES blog for tunning the indexing speed请参阅ES 博客以调整索引速度

  1. We are planning to use update API to update a field, Will it reindex the whole document?我们计划使用更新 API 来更新一个字段,它会重新索引整个文档吗? Is there any option to update only a specific field without reindexing other fields?是否有任何选项可以仅更新特定字段而不重新索引其他字段?

Yes, even if you update a field, internally elasticsearch marks the old document deleted(soft deleted) and creates a new document and later on during segment merging old deleted document is actually deleted.是的,即使您更新了一个字段,在内部 elasticsearch 标记旧文档已删除(软删除)并创建一个新文档,然后在分段合并旧删除文档期间实际删除。 More info on the partial update of ES is covered in detail by Elastician in this SO answer Elastician在此 SO 答案中详细介绍了有关 ES 部分更新的更多信息

  1. It will be good if we have two index or a index with two types, one for profile other for a summary?如果我们有两个索引或具有两种类型的索引会很好,一种用于概要文件,另一种用于摘要?

It depends, if while querying you need to look in both the index( types are deprecated in the latest version ), then it doesn't make sense to create two indexes, as denormalized data will give a better search performance.这取决于,如果在查询时需要同时查看两个索引( 类型在最新版本中已弃用),那么创建两个索引是没有意义的,因为非规范化数据将提供更好的搜索性能。

Also creating two indices with a join will be a bit complex to implement, and anyway as you need to frequently update the transaction data for the author, which would have the most of the sellar data and updates on the big index is more costly, so even if you save updates on profile index but still as it would be very small, IMHO it wouldn't give much better performance but that you can test with some stress testing.此外,使用连接创建两个索引实施起来会有点复杂,而且无论如何您需要经常为作者更新交易数据,这将拥有最多的卖方数据,而大索引的更新成本更高,所以即使您在配置文件索引上保存更新但仍然非常小,恕我直言,它不会提供更好的性能,但您可以通过一些压力测试进行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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