_index元数据
- 表明一个document存放在哪一个index中
- 相似的数据放在一个索引中,非相似的数据放在不一样的索引中:product index(包含了全部的商品)、sales index(包含了全部的商品销售数据)、inventory index(包含了全部库存的相关数据)
- index中包含了不少相似的document: 相似是什么意思呢,其实指的就是说,这些document的fields很大一部分是相同的,你说你放了3个document,每一个document的fields都彻底不同,这就不是相似了,就不太适合放到一个index里面去了
- 索引名称必须是小写,不能用下划线开头,不包含逗号
_type元数据
- 表明document属于index的哪一个类别
- 一个索引一般会划分为多个type,逻辑上对index有些许不一样的几类数据进行分类
- type名称能够是大写或者小写,可是同时不能用下划线开头,不能包含逗号
_id元数据
- 表明document的惟一标识,与_index和_type一块儿能够起惟一标识和定位一个document
- 咱们能够手动指定document的id,也能够不指定,由es自动为咱们建立一个id
1、_source元数据
创建一条数据
put /test_index/test_type/1 { "test_field1": "test_field1", "test_field2": "test_field2" } get /test_index/test_type/1 { "_index": "test_index", "_type": "test_type", "_id": "3", "_version": 1, "found": true, "_source": { "test_field1": "test_field1", "test_field2": "test_field2" } } _source元数据:就是说,我们在创建一个document的时候,使用的那个放在request body中的json串,默认情况下,在get的时候,会原封不动的给我们返回回来。 定制返回的结果,指定_source中,返回哪些field GET /test_index/test_type/1?_source=test_field1,test_field2 { "_index": "test_index", "_type": "test_type", "_id": "1", "_version": 2, "found": true, "_source": { "test_field2": "test_field2" } }
2、定制返回结果
定制返回的结果,指定_source中,返回哪些field。多个可用用 , 分割