es-多文档简单查询(_mget)

1。多文档查询

(1)url:POST http://localhost:9200/_mget?pretty/

       参数:

{
	"docs": [{
		"_index": "myes",
		"_type": "name",
		"_id": "1"
	}, {
		"_index": "myes",
		"_type": "name",
		"_id": "3"
	}]
}

  结果:

 

2.上面的还可以简写(如果在相同索引,相同type)

 

 (1)url:POST http://localhost:9200/myes/_mget?pretty/

        参数:

{
	"docs": [{
		"_type": "name",
		"_id": "1"
	}, {
		"_type": "name",
		"_id": "3"
	}]
}

(2)url:POST http://localhost:9200/myes/name/_mget?pretty/

       参数:

{
	"docs": [{
		"_id": "1"
	}, {
		"_id": "3"
	}]
}

  或者:

{
	"ids": ["1","3"]
}

  

 结果和上面是一致的,但是对于不同个索引,不同映射的就不能这样简写了。

同时也可以指定返回字段

 

posted @ 2018-08-05 14:45  anxbb  阅读(994)  评论(0编辑  收藏  举报