在kibana中包含兩種策略:doc和search。使用了兩個循環隊列來獲取請求,並進行響應。
doc的代碼如下:
clientMethod: 'mget'
search的代碼如下:
clientMethod: 'msearch'
通過查詢api可以發現:
mget命令,可以執行多個查詢。但是查詢條件基本是index,type,id這種
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){
// ...
});
或者
client.mget({
index: 'myindex',
type: 'mytype',
body: {
ids: [1, 2, 3]
}
}, function(error, response){
// ...
});
msearch命令,則可以實現復雜的查詢,例如:
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"' } } }
]
});