博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
elasticsearch _source字段的一些说明
阅读量:6340 次
发布时间:2019-06-22

本文共 2856 字,大约阅读时间需要 9 分钟。

_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  or .

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 } } } }
Warning

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 , , and  APIs.
  • On the fly .
  • 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.
Tip

If disk space is a concern, rather increase the  instead of disabling the _source.

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.

Warning

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  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 _source field.

We can still search on this field, even though it is not in the stored _source.

本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/bonelee/p/6439120.html
,如需转载请自行联系原作者
你可能感兴趣的文章
.Net 转战 Android 4.4 日常笔记(6)--Android Studio DDMS用法
查看>>
SVN被锁定的几种解决方法
查看>>
182在屏幕中实现网格化视图效果
查看>>
Dundas 系列
查看>>
巧用AJAX技术,通过updatePanel控件实现局部刷新
查看>>
20140420技术交流活动总结
查看>>
SaltStack配置salt-api
查看>>
各种情况下block的类型
查看>>
ThinkPHP 3.2.x 集成极光推送指北
查看>>
js作用域链
查看>>
java中如何选择Collection Class--java线程(第3版)
查看>>
为运维人员插上腾飞更远的翅膀!
查看>>
Word 2003中编辑标记与格式标记大讨论
查看>>
调试网页PAIP HTML的调试与分析工具
查看>>
路径工程OpenCV依赖文件路径自动添加方法
查看>>
玩转SSRS第七篇---报表订阅
查看>>
WinCE API
查看>>
Linux常用基本命令[cp]
查看>>
CSS 相对|绝对(relative/absolute)定位系列(一)
查看>>
关于 Nginx 配置 WebSocket 400 问题
查看>>