💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
[TOC] # 简介 为了能更快的同时检索多个文档 mget API参数是一个docs数组,数组的每个节点定义一个文档的`_index,_type,_id`元数据 ![](https://img.kancloud.cn/cd/51/cd516b1313a2d795b73d5c6bd8be413e_278x484.png) 我们先创建出一些数据,然后我们看下 ~~~ GET /library/books/1 GET /library/books/2 GET /library/books/3 GET /shakespeare/line/1 GET /shakespeare/line/2 GET /shakespeare/line/3 ~~~ # 一起获取下 ~~~ # 数组[] GET /_mget { "docs": [ { "_index": "library", "_type": "books", "_id": 1 }, { "_index": "library", "_type": "books", "_id": 2 }, { "_index": "library", "_type": "books", "_id": 3 }, { "_index": "shakespeare", "_type": "line", "_id": 1 }, { "_index": "shakespeare", "_type": "line", "_id": 2 }, { "_index": "shakespeare", "_type": "line", "_id": 3 } ] } ~~~ # 可以指定你想获取的字段 ~~~ # 也可以指定_source字段,获取你想要的 GET /_mget { "docs": [ { "_index": "library", "_type": "books", "_id": 1, "_source": "title" }, { "_index": "library", "_type": "books", "_id": 2, "_source": "name" }, { "_index": "library", "_type": "books", "_id": 3, "_source": "price" }, { "_index": "shakespeare", "_type": "line", "_id": 1, "_source": "name" }, { "_index": "shakespeare", "_type": "line", "_id": 2, "_source": ["name","password"] }, { "_index": "shakespeare", "_type": "line", "_id": 3, "_source": "password" } ] } ~~~ # 获取相同index相同type下不同ID的文档 ~~~ GET /library/books/_mget { "docs": [ {"_id": 1}, {"type":"books","_id":3} ] } ~~~ # 可以这样简便的写 ~~~ GET /library/books/_mget { "ids": ["1", "3"] } ~~~