簡體   English   中英

Elasticsearch-如何使JavaScript客戶端響應超過10個項目

[英]Elasticsearch - How to make JavaScript client response more than 10 items

我正在為Elasticsearch使用JavaScript客戶端 我對請求有疑問:

client.search({
      index: applicationIndex,
      type: applicationType,
      body: {
        query: {
          match_all : {}
        }
      }
    })
    .then(function(res){
      return {res: res};
    });

它不返回超過10個項目。 如何退貨(實際上有21件商品)? 謝謝

在文檔中,它指出size默認為10。將size添加到搜索對象中,並將其值設置為21

嘗試這個

client.search({
      index: applicationIndex,
      type: applicationType,
      size: 21,
      body: { 
        query: {
          match_all : {}
        }
      }
    })
    .then(function(res){
      return {res: res};
    });

您還可以使用“ from”參數添加“ size”一個來管理分頁:)

client.search({
  index: applicationIndex,
  type: applicationType,
  size: 10,
  from: 10,
  body: { 
    query: {
      match_all : {}
    }
  }
})
.then(function(res){
  return {res: res};
});

在這里它將返回介於10和20之間的元素:)

玩一下Elasticsearch :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM