Kibana中doc与search策略的区别

在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"' } } }
  ]
});
posted @ 2015-11-03 15:39  xingoo  阅读(2431)  评论(0编辑  收藏  举报