弹性搜索商店字段vs _source [英] Elasticsearch store field 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:
- 您将无法进行部分更新
- 您将无法从您的
Elasticsearch群集中的JSON重新索引您的数据,您必须从数据源
(通常很多)重新索引较慢)。
这篇关于弹性搜索商店字段vs _source的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!