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"' } } }
  ]
});
相關文章
相關標籤/搜索