Both strategies included in the kibana: doc and search. Used two circular queue acquisition request, and responds.
doc code is as follows:clientMethod: 'mget'
search code is as follows:clientMethod: 'msearch'
It can be found by querying api:
mget command, you can execute multiple queries. But the query is basically index, type, id this
client.mget({
body: {
docs: [
{ _index: 'indexA', _type: 'typeA', _id: '1' },
{ _index: 'indexB', _type: 'typeB', _id: '1' },
{ _index: 'indexC', _type: 'typeC', _id: '1' }
]
}
}, function(error, response){
// ...
});
or
client.mget({
index: 'myindex',
type: 'mytype',
body: {
ids: [1, 2, 3]
}
}, function(error, response){
// ...
});
msearch command, you can implement complex queries, such as:
client.msearch({
body: [
// match all query, on all indices and types
{},
{ query: { match_all: {} } },
// query_string query, on index/mytype
{ _index: 'myindex', _type: 'mytype' },
{ query: { query_string: { query: '"Test 1"' } } }
]
});
Reproduced in: https: //my.oschina.net/u/204616/blog/545019