如何计算弹性搜索索引中给定类型的统计信息

时间:2015-10-14 01:16:52

标签: elasticsearch

我知道With CTE As ( Select Row_Number() Over (Partition By AccountID Order By DateTimeEntered Desc) As recentID, AccountID, Docket_NO From dbo.messages Where Docket_NO <> '' ) Update C Set CaseNumber = L.Docket_NO From dbo.Cases as C Inner Join CTE as L On L.AccountID = C.AccountID And L.recentID = 1 Where L.Docket_NO != C.CaseNumber Or C.CaseNumber Is Null API为一个或多个索引提供索引级别统计信息。我对_stats参数特别感兴趣,该参数是索引的大小(以字节为单位)。我想计算索引中给定类型的大小(以字节为单位),但是

store

不会返回curl http://localhost:9200/myIndex/_stats/indexing?types=myType的字节大小。是否有一个API可以为我提供以下统计信息:myType的大小为Xgb,代表myType的Y%?

2 个答案:

答案 0 :(得分:0)

您需要使用/store子路径而不是/indexing子路径,如下所示:

curl http://localhost:9200/myIndex/_stats/store?types=myType
                                            ^
                                            |
                                     use "store" here

您将获得您感兴趣的所有store数据

{
  "_shards" : {
    "total" : 15,
    "successful" : 15,
    "failed" : 0
  },
  "_all" : {
    "primaries" : {
      "store" : {
        "size_in_bytes" : 2250058413,
        "throttle_time_in_millis" : 0
      }
    },
    "total" : {
      "store" : {
        "size_in_bytes" : 2250058413,
        "throttle_time_in_millis" : 0
      }
    }
  },
  "indices" : {
    "myIndex" : {
      "primaries" : {
        "store" : {
          "size_in_bytes" : 1444291,
          "throttle_time_in_millis" : 0
        }
      },
      "total" : {
        "store" : {
          "size_in_bytes" : 1444291,
          "throttle_time_in_millis" : 0
        }
      }
    },
    ...
  }
}

答案 1 :(得分:0)

以上仅适用于索引。您正在指定类型,但您仍然可以看到所有类型的商店。