26.store
-
是否单独存储该字段
-
store配置值
其实不管你将store设置为true or false, elasticsearch都将为我们存储这些field, 不同的是:
1.当store为false时(默认配置),这些field只存储在"_source" field中。
2.当store为true时,这些field的value会存储在一个跟 _source 平级的独立的field中。同时也会存储在_source中,所以有两份拷贝。 -
store应用场景
1._source field在索引的mapping 中disable了。
这种情况下,如果不将某个field定义成store=true,那些将无法在返回的查询结果中看到这个field。
2._source的内容非常大。
##这时候如果我们想要在返回的_source document中解释出某个field的值的话,开销会很大(当然你也可以定义source filtering将减少network overhead),比如某个document中保存的是一本书,所以document中可能有这些field: title, date, content。假如我们只是想查询书的title 跟date信息,而不需要解释整个_source(非常大),这个时候我们可以考虑将title, date这些field设置成store=true。
DELETE my-index-000001
## 标题title和日期date字段被存储。store=true
## 内容content 不被存储,store=false
PUT my-index-000001
{
"mappings": {
"properties": {
"title": {
"type": "text",
"store": true
},
"date": {
"type": "date"