ElasticSearch 7.x 实战入门05
2020-03-23 本文已影响0人
众神开挂
内容比较简单: document 元数据,_source元数据的讲解
1、 document 核心元数据
{
"_index": "test_index",
"_type": "test_type",
"_id": "1",
"_version": 1,
"found": true,
"_source": {
"test_content": "test test"
}
}
1、_index元数据
(1)代表一个document存放在哪个index中
(2)index中包含了很多类似的document:类似的数据和支持的需求是相同的,相同功能的数据放在独立的shard中,不与其他数据相互影响。
(3)索引名称必须是小写的,不能用下划线开头,不能包含逗号:product,website,blog
2、_type元数据
在 ES7 中已取消,默认只有一种type 就是 _doc
,可以多学一些其他东西
3、_id元数据
(1)代表document的唯一标识,与index和type一起,可以唯一标识和定位一个document
(2)我们可以手动指定document的id(put /index/_doc/id),也可以不指定,由es自动为我们创建一个id
2、_source元数据
_source元数据:就是说,我们在创建一个document的时候,使用的那个放在request body中的json串,默认情况下,在get的时候,会原封不动的给我们返回来。
1、_source过滤
1、不显示_source
GET /ecommerce/_search
{
"_source": "false"
}
2、显示部分_source
GET /ecommerce/_search
{
"_source": "name"
}
GET /ecommerce/_search
{
"_source": [
"name",
"tags"
]
}
3、包含或排除某些列
GET /ecommerce/_search
{
"_source": {
"includes": [
"price",
"tags"
],
"excludes": "name"
}
}