限制为1000的记录数(ElasticSearch上的R客户端)

时间:2016-12-14 11:33:22

标签: r elasticsearch

我用R查询ElasticSearch(使用弹性客户端),似乎我无法达到超过1000条记录。即使$hits$total返回4187。

以下是应用于返回列表时str函数的第一行。

List of 4
$ took     : int 1844
$ timed_out: logi FALSE
$ _shards  :List of 3
  ..$ total     : int 692
  ..$ successful: int 692
  ..$ failed    : int 0
$ hits     :List of 3
  ..$ total    : int 4187
  ..$ max_score: num 1
  ..$ hits     :List of 1000

如果我将查询限制为较少的记录,我就不会遇到此问题。以下是应用于返回列表时str函数的第一行,我们看到$hits$total等于返回列表的数量 - $hits$hits

List of 4
$ took     : int 157
$ timed_out: logi FALSE
$ _shards  :List of 3
  ..$ total     : int 692
  ..$ successful: int 692
  ..$ failed    : int 0
$ hits     :List of 3
  ..$ total    : int 13
  ..$ max_score: num 1
  ..$ hits     :List of 13

我想这可能是由于某些配置参数,因为这个限制是如此精确。如何避免此限制并访问所有列表/记录数?

编辑 :(已添加信息)

参数body

bdy <- '{
"id": "getKpiHistMetric",
"params": {"KpiKey":"Agg:Net|SL,Wind:10min,Net:PT,SL:1,Metric:Rate",
"from": "2016-11-01T00:00:00",
"to": "2016-11-30T23:59:59"}
}'

在整个列表上进行交互时出现错误。首先,我创建一个空的data.frame

df <- data.frame(DATE = integer(),
                 TICK = integer(),
                 VALUE = double(), stringsAsFactors = FALSE)

然后我填写它:

for(i in 1:q$hits$total){

  a <- as.Date(as.POSIXct(q$hits$hits[[i]]$`_source`$Timestamp/1000, origin="1970-01-01"), format = "%m/%d/%y")
  b <- strftime(as.POSIXct(round(q$hits$hits[[i]]$`_source`$Timestamp/1000, -1), origin="1970-01-01"), format = "%H:%M")
  c <- q$hits$hits[[i]]$`_source`$Value

  df.row <- data.frame(DATE = a, TICK = b, VALUE = c, stringsAsFactors = FALSE)
  df <- rbind(df, df.row)

}

此时我收到以下错误:

Error in q$hits$hits[[i]] : subscript out of bounds

目前,i = 1001

1 个答案:

答案 0 :(得分:0)

记录数限制为1000的原因是弹性搜索配置。这是我从数据库维护团队得到的答案。