Elasticsearch 存储字段 vs _source [英] Elasticsearch store field vs _source

查看:39
本文介绍了Elasticsearch 存储字段 vs _source的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Elasticsearch 1.4.3

Using Elasticsearch 1.4.3

我正在构建一种报告"系统.客户可以挑选他们想要在结果中返回的字段.

I'm building a sort of "reporting" system. And the client can pick and chose which fields they want returned in their result.

在 90% 的情况下,客户端永远不会选择所有字段,所以我想我可以在映射中禁用 _source 字段以节省空间.但后来我知道

In 90% of the cases the client will never pick all the fields, so I figured I can disable _source field in my mapping to save space. But then I learned that

GET myIndex/myType/_search/
{
    "fields": ["field1", "field2"]
    ...
}

不返回字段.

所以我假设我必须对每个字段使用 "store": true.从我读到的内容来看,搜索速度会更快,但我想在空间方面它将与 _source 相同,或者我们仍然可以节省空间?

So I assume I have to then use "store": true for each field. From what I read this will be faster for searches, but I guess space wise it will be the same as _source or we still save space?

推荐答案

_source 字段存储您发送到 Elasticsearch 的 JSON,您可以选择仅在需要时返回某些字段,这非常适合你的用例.我从未听说过存储字段的搜索速度会更快._source 字段在磁盘空间上可能更大,但如果您必须存储每个字段,则无需在 _source 字段上使用存储的字段.如果您确实禁用了源字段,则意味着:

The _source field stores the JSON you send to Elasticsearch and you can choose to only return certain fields if needed, which is perfect for your use case. I have never heard that the stored fields will be faster for searches. The _source field could be bigger on disk space, but if you have to store every field there is no need to use stored fields over the _source field. If you do disable the source field it will mean:

  • 您将无法进行部分更新
  • 您将无法从 JSON 重新索引您的数据Elasticsearch 集群,你必须从数据源重新索引(通常会慢很多).

这篇关于Elasticsearch 存储字段 vs _source的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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