太多字段对弹性搜索索引不利? [英] Too many fields bad for elasticsearch index?

查看:28
本文介绍了太多字段对弹性搜索索引不利?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一千个键,我想存储相关的值.直观的方法似乎类似于

Let say I have a thousand keys, and I would want to store the associated values. The intuitive approach seems to be something like

{
   "key1":"someval",
   "key2":"someotherval",
    ...
}

对于具有数千个键的弹性搜索索引来说,这是一种糟糕的设计模式吗?以这种方式引入的每个键是否会为索引下的每个文档产生开销?

Is this a bad design pattern for elasticsearch index to have thousands of keys? Would each keys introduced this way create overhead for every documents under the index?

推荐答案

如果您知道您将拥有的键数量有上限,那么几千个字段不是问题.

If you know there is an upper limit to the number of keys you'll have, a few thousand fields is not a problem.

问题是当你有一组无限的键时,例如当键从一个值派生时,您将拥有一个不断增长的映射,因此还有集群状态.它还可能导致古怪的搜索.

The problem is when you have an unbounded set of keys, e.g. when the key is derived from a value, as you'll have a continuously growing mapping and thus also cluster state. It can also lead to quirky searches.

这是一个足够常见的问题/问题,我在关于 Elasticsearch 搜索疑难解答,适合初学者.

This is a common enough question/issue that I dedicated a section to it in my article on Troubleshooting Elasticsearch searches, for Beginners.

简而言之,数千个字段没有问题 - 无法控制映射.

In short, thousands of fields is no problem - not having control of the mapping is.

这篇关于太多字段对弹性搜索索引不利?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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