elasticsearch _source字段的一些说明
_source field
The _source field contains the original JSON document body that was passed at index time. The_source field itself is not indexed (and thus is not searchable), but it is stored so that it can be returned when executing fetch requests, like get or search.
Disabling the _source field
Though very handy to have around, the source field does incur storage overhead within the index. For this reason, it can be disabled as follows:
PUT tweets
{
"mappings": {
"tweet": {
"_source": {
"enabled": false
}
}
}
}
Think before disabling the _source field
Users often disable the _source field without thinking about the consequences, and then live to regret it. If the _source field isn’t available then a number of features are not supported:
- The
update,update_by_query, andreindexAPIs. - On the fly highlighting.
- The ability to reindex from one Elasticsearch index to another, either to change mappings or analysis, or to upgrade an index to a new major version.
- The ability to debug queries or aggregations by viewing the original document used at index time.
- Potentially in the future, the ability to repair index corruption automatically.
If disk space is a concern, rather increase the compression level instead of disabling the _source.
The metrics use case
The metrics use case is distinct from other time-based or logging use cases in that there are many small documents which consist only of numbers, dates, or keywords. There are no updates, no highlighting requests, and the data ages quickly so there is no need to reindex. Search requests typically use simple queries to filter the dataset by date or tags, and the results are returned as aggregations.
In this case, disabling the _source field will save space and reduce I/O. It is also advisable to disable the _all field in the metrics case.
Including / Excluding fields from _source
An expert-only feature is the ability to prune the contents of the _source field after the document has been indexed, but before the _source field is stored.
Removing fields from the _source has similar downsides to disabling _source, especially the fact that you cannot reindex documents from one Elasticsearch index to another. Consider using source filtering instead.
The includes/excludes parameters (which also accept wildcards) can be used as follows:
PUT logs
{
"mappings": {
"event": {
"_source": {
"includes": [
"*.count",
"meta.*"
],
"excludes": [
"meta.description",
"meta.other.*"
]
}
}
}
} PUT logs/event/1
{
"requests": {
"count": 10,
"foo": "bar"
},
"meta": {
"name": "Some metric",
"description": "Some metric description",
"other": {
"foo": "one",
"baz": "two"
}
}
} GET logs/event/_search
{
"query": {
"match": {
"meta.other.foo": "one"
}
}
}
|
|
These fields will be removed from the stored |
|
|
We can still search on this field, even though it is not in the stored |
elasticsearch _source字段的一些说明的更多相关文章
- elasticsearch的store属性 vs _source字段
众所周知_source字段存储的是索引的原始内容,那store属性的设置是为何呢?es为什么要把store的默认取值设置为no?设置为yes是否是重复的存储呢? 我们将一个field的值写入es中,要 ...
- elasticsearch的store属性跟_source字段——如果你的文档长度很长,存储了_source,从_source中获取field的代价很大,你可以显式的将某些field的store属性设置为yes,否则设置为no
转自:http://kangrui.iteye.com/blog/2262860 众所周知_source字段存储的是索引的原始内容,那store属性的设置是为何呢?es为什么要把store的默认取值设 ...
- ElasticStack系列之八 & _source 字段
有很多人会有这样的一个疑问: _source字段存储的是索引的原始内容,那 store 属性的设置是为何呢?elasticsearch 为什么要把 store 的默认取值设置为 no?设置为 yes ...
- ES _source字段介绍——json文档,去掉的话无法更新部分文档,最重要的是无法reindex
摘自:https://es.xiaoleilu.com/070_Index_Mgmt/31_Metadata_source.html The _source field stores the JSON ...
- elasticsearch _source
默认地,Elasticsearch 在 _source 字段存储代表文档体的JSON字符串.和所有被存储的字段一样, _source 字段在被写入磁盘之前先会被压缩.这个字段的存储几乎总是我们想要的, ...
- [Elasticsearch] 多字段搜索 (三) - multi_match查询和多数字段 <译>
multi_match查询 multi_match查询提供了一个简便的方法用来对多个字段执行相同的查询. NOTE 存在几种类型的multi_match查询,其中的3种正好和在“了解你的数据”一节中提 ...
- Elasticsearch - 理解字段分析过程(_analyze与_explain)
我们经常会遇到问题.为什么指定的文档没有被搜索到.许多情况下, 这都归因于映射的定义和分析例程配置存在问题. 针对分析过程的调试,ElasticSearch提供了专用的REST API. _analy ...
- Elasticsearch 多字段搜索
查询很少是对一个字段做 match 查询,通常都是一个 query 查询多个字段,比如一个 doc 有 title.content.pagetag 等文本字段,要在这些字段查询含多个 term 的 q ...
- [Elasticsearch] 多字段搜索 (三) - multi_match查询和多数字段
multi_match查询 multi_match查询提供了一个简便的方法用来对多个字段执行相同的查询. NOTE 存在几种类型的multi_match查询,其中的3种正好和在"了解你的数据 ...
随机推荐
- Easy UI form表单提交 IE浏览器不执行success ,以及 datagrid 展示过慢
最近在做一个Easy ui的项目 发现了一些问题,在这里总结下 1.表单提交,后端代码 public ActionResult Save(Request model) { ResultInfo _in ...
- Linux禁止Ctrl+Alt+Del重新启动
方法1:改动/etc/inittab 屏蔽 ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now 或者删除改行内容 保存退出 适用对象:RedHat4.8 ...
- svn自动部署
版本库目录hooks下创建post-commit.bat TortoiseProc.exe /command:update /path:"E:\web_server\sial\" ...
- windows下rsync部署安装
windows下rsync部署安装 2012-06-05 12:06:13| 分类: 系统 | 标签:rsync windows |字号 订阅 rsync在windows与windows ...
- Spring学习八----------Bean的配置之Resources
© 版权声明:本文为博主原创文章,转载请注明出处 Resources 针对于资源文件的统一接口 -UrlResource:URL对应的资源,根据一个URL地址即可创建 -ClassPathResour ...
- RPMBUILD源码打包资源汇总(转)
http://mattshma.github.io/2015/11/04/rpm%E6%89%93%E5%8C%85/ http://400053.blog.51cto.com/390053/7210 ...
- 【LeetCode从零单排】No.135Candy(双向动态规划)
1.题目 There are N children standing in a line. Each child is assigned a rating value. You are giving ...
- BZOJ 1002 FJOI2007 轮状病毒 递推+高精度
题目大意:轮状病毒基定义如图.求有多少n轮状病毒 这个递推实在是不会--所以我选择了打表找规律 首先执行下面程序 #include<cstdio> #include<cstring& ...
- VS2017快捷键
1.回到上一个光标位置/前进到下一个光标位置 (1)回到上一个光标位置:使用组合键“Ctrl + -”; (2)前进到下一个光标位置:“Ctrl + Shift + - ”. 2.复制/剪切/删除整行 ...
- nstall-Package : 无法找到程序包“MySql.Data.Entity.EF6”
在vs2013中用MySQL+EF6时,会遇到版本的问题,解决方法一般如下: 1 Install-Package EntityFramework -Version 6.0.0然后Enter2 Inst ...