弹性搜索、多个索引 vs 一个索引和不同数据集的类型? [英] Elastic search, multiple indexes vs one index and types for different data sets?

查看:24
本文介绍了弹性搜索、多个索引 vs 一个索引和不同数据集的类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 MVC 模式开发的应用程序,现在我想为它的多个模型建立索引,这意味着每个模型都有不同的数据结构.

I have an application developed using the MVC pattern and I would like to index now multiple models of it, this means each model has a different data structure.

  • 使用多个索引更好,每个模型一个,还是每个模型在同一索引中都有一个类型?我认为这两种方式都需要不同的搜索查询.我刚刚开始.

  • Is it better to use mutliple indexes, one for each model or have a type within the same index for each model? Both ways would also require a different search query I think. I just started on this.

如果数据集很小或很大,这两个概念在性能方面是否存在差异?

Are there differences performancewise between both concepts if the data set is small or huge?

如果有人可以为此目的向我推荐一些好的样本数据,我会自己测试第二个问题.

I would test the 2nd question myself if somebody could recommend me some good sample data for that purpose.

推荐答案

这两种方法有不同的含义.

There are different implications to both approaches.

假设您使用的是 Elasticsearch 的默认设置,为每个模型设置 1 个索引将显着增加您的分片数量,因为 1 个索引将使用 5 个分片,5 个数据模型将使用 25 个分片;虽然在 1 个索引中有 5 个对象类型仍将使用 5 个分片.

Assuming you are using Elasticsearch's default settings, having 1 index for each model will significantly increase the number of your shards as 1 index will use 5 shards, 5 data models will use 25 shards; while having 5 object types in 1 index is still going to use 5 shards.

将每个数据模型作为索引的含义:

Implications for having each data model as index:

  • 在索引内搜索高效且快速,因为每个分片中的数据量应该更小,因为它分布到不同的索引.
  • 从 2 个或更多索引中搜索数据模型的组合会产生开销,因为必须将查询发送到索引中的更多分片、编译并发送回用户.
  • 如果您的数据集很小,则不推荐使用,因为每创建一个额外的分片都会产生更多的存储空间,并且性能提升微乎其微.
  • 推荐如果您的数据集很大并且您的查询需要很长时间来处理,因为专用分片存储您的特定数据并且 Elasticsearch 会更容易处理.

将每个数据模型作为索引中的对象类型的含义:

Implications for having each data model as an object type within an index:

  • 更多数据将存储在索引的 5 个分片中,这意味着当您跨不同数据模型查询时开销问题较少,但分片大小会显着增大.
  • 分片中的数据越多,Elasticsearch 搜索所需的时间就越长,因为要过滤的文档越多.
  • 如果您知道要处理 1 TB 的数据,并且没有将数据分布在 Elasticsearch 映射中的不同索引或多个分片中,则不建议这样做.
  • 推荐用于小型数据集,因为您不会因为每个分片占用硬件空间而浪费存储空间以获得边际性能提升.

如果您要问什么是太多数据与小数据?通常,它取决于处理器速度和硬件的 RAM、存储在 Elasticsearch 映射中的每个变量中的数据量以及查询要求;在您的查询中使用多个方面会显着减慢您的响应时间.对此没有直接的答案,您必须根据自己的需要进行基准测试.

If you are asking what is too much data vs small data? Typically it depends on the processor speed and the RAM of your hardware, the amount of data you store within each variable in your mapping for Elasticsearch and your query requirements; using many facets in your queries is going to slow down your response time significantly. There is no straightforward answer to this and you will have to benchmark according to your needs.

这篇关于弹性搜索、多个索引 vs 一个索引和不同数据集的类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆