Elasticsearch学习笔记(五)索引元数据和集群元数据

时间:2023-03-08 18:44:28

一、索引元数据

执行:GET /ecommerce/product/1

返回结果:

{
   "_index": "ecommerce",
   "_type": "product",
   "_id": "1",
   "_version": 1,
   "found": true,
   "_source": {
     "name": "gaolujie yagao",
     "desc": "gaoxiao meibai",
     "price": 30,
     "producer": "gaolujie producer",
     "tags": [
       "meibai",
       "fangzhu"
     ]
   }

}

Elasticsearch学习笔记(五)索引元数据和集群元数据

二、集群元数据

三、document的_source元数据

添加document:   
         PUT /test_index/test_type/1

{
   "test_field1": "test field1",
   "test_field2": "test field2"

}

查询指定document:

GET  /test_index/test_type/1

{
   "_index": "test_index",
   "_type": "test_type",
   "_id": "1",
   "_version": 2,
   "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"
   }

}