/stats 路由提供关于索引和 Meilisearch 数据库的详细信息和指标。

统计对象

{
  "databaseSize": 447819776,
  "usedDatabaseSize": 196608,
  "lastUpdate": "2019-11-15T11:15:22.092896Z",
  "indexes": {
    "movies": {
      "numberOfDocuments": 19654,
      "numberOfEmbeddedDocuments": 1,
      "numberOfEmbeddings": 1,
      "rawDocumentDbSize": 5320,
      "avgDocumentSize": 92,
      "isIndexing": false,
      "fieldDistribution": {
        "poster": 19654,
        "overview": 19654,
        "title": 19654,
        "id": 19654,
        "release_date": 19654
      }
    },
    "books": {
      "numberOfDocuments": 5,
      "numberOfEmbeddedDocuments": 5,
      "numberOfEmbeddings": 10,
      "rawDocumentDbSize": 8780,
      "avgDocumentSize": 422,
      "isIndexing": false,
      "fieldDistribution": {
        "id": 5,
        "title": 5,
        "author": 5,
        "price": 5, 
        "genres": 5
      }
    }
  }
}
名称类型描述
databaseSize整数Meilisearch 和 LMDB 占用的存储空间(字节)
usedDatabaseSize整数数据库使用的存储空间(字节),不包括 LMDB 占用的未使用空间
lastUpdate字符串数据库最后一次更新的时间,采用 RFC 3339 格式
indexes对象包含数据库中每个索引统计信息的对象
numberOfDocuments整数索引中的文档总数
numberOfEmbeddedDocuments整数至少包含一个嵌入的文档总数
numberOfEmbeddings整数索引中嵌入的总数
rawDocumentDbSize整数索引中所有文档占用的存储空间(字节)
avgDocumentDbSize整数索引中存储的文档总大小除以该索引中的文档数量
isIndexing布尔值如果为 true,则索引仍在处理文档,此时尝试搜索将导致未定义行为
fieldDistribution对象显示索引中的每个字段以及该索引中包含该字段的文档总数

fieldDistribution 不受 searchableAttributesdisplayedAttributes 影响。即使某个字段未被显示或不可搜索,它仍将出现在 fieldDistribution 对象中。

获取所有索引的统计信息

GET
/stats

获取所有索引的统计信息。

示例

curl \
  -X GET 'MEILISEARCH_URL/stats'

响应:200 Ok

{
  "databaseSize": 447819776,
  "usedDatabaseSize": 196608,
  "lastUpdate": "2019-11-15T11:15:22.092896Z",
  "indexes": {
    "movies": {
      "numberOfDocuments": 19654,
      "numberOfEmbeddedDocuments": 1,
      "numberOfEmbeddings": 1,
      "rawDocumentDbSize": 2087,
      "avgDocumentSize": 41,
      "isIndexing": false,
      "fieldDistribution": {
        "poster": 19654,
        "overview": 19654,
        "title": 19654,
        "id": 19654,
        "release_date": 19654
      }
    },
    "books": {
      "numberOfDocuments": 5,
      "numberOfEmbeddedDocuments": 5,
      "numberOfEmbeddings": 10,
      "isIndexing": false,
      "fieldDistribution": {
        "id": 5,
        "title": 5,
        "author": 5,
        "price": 5, 
        "genres": 5
      }
    }
  }
}

获取单个索引的统计信息

GET
/indexes/{index_uid}/stats

获取单个索引的统计信息。

路径参数

名称类型描述
index_uid *字符串请求索引的 uid

示例

curl \
  -X GET 'MEILISEARCH_URL/indexes/movies/stats'

响应:200 Ok

{
  "numberOfDocuments": 19654,
  "numberOfEmbeddedDocuments": 1,
  "numberOfEmbeddings": 1,
  "rawDocumentDbSize": 3618,
  "avgDocumentSize": 104,
  "isIndexing": false,
  "fieldDistribution": {
    "poster": 19654,
    "overview": 19654,
    "title": 19654,
    "id": 19654,
    "release_date": 19654
  }
}