Kibana中doc与search策略的区别

在kibana中包含两种策略:doc和search。使用了两个循环队列来获取请求,并进行响应。

doc的代码以下:
clientMethod: 'mget'api

search的代码以下:
clientMethod: 'msearch'code

经过查询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){
  // ...
});

或者get

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"' } } }
  ]
});
相关文章
相关标签/搜索