From ceefe24530fb34c70e754e81e061258f7a41cc60 Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Fri, 26 Apr 2024 17:13:56 +0100 Subject: [PATCH] Fix cluster level dense vector stats The cluster level dense vector stats returns the total number of dense vector indices globally including the replicas. This commit fixes the total to only include the value count of the primary indices. This change aligns with the docs stats which also reports the number of primary documents when used in cluster stats. The indices stats API still reports granular results for replicas and primaries so the information is not lost. --- docs/reference/cluster/stats.asciidoc | 3 ++- docs/reference/rest-api/common-parms.asciidoc | 6 ++++++ .../resources/rest-api-spec/test/cluster.stats/10_basic.yml | 4 ---- .../action/admin/cluster/stats/ClusterStatsIndices.java | 2 +- .../org/elasticsearch/rest/action/cat/RestShardsAction.java | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/reference/cluster/stats.asciidoc b/docs/reference/cluster/stats.asciidoc index 26b3553c3c17..13d126309714 100644 --- a/docs/reference/cluster/stats.asciidoc +++ b/docs/reference/cluster/stats.asciidoc @@ -952,7 +952,8 @@ Contains statistics about indexed dense vector used in selected nodes. ===== `value_count`:: (integer) -Total number of dense vector indexed in selected nodes. +Total number of dense vector indexed across all primary shards assigned to +selected nodes. ===== ==== diff --git a/docs/reference/rest-api/common-parms.asciidoc b/docs/reference/rest-api/common-parms.asciidoc index e63f66217d8d..f6e4e4831819 100644 --- a/docs/reference/rest-api/common-parms.asciidoc +++ b/docs/reference/rest-api/common-parms.asciidoc @@ -556,6 +556,12 @@ Size of the index in <>. `translog`:: <> statistics. + +`dense_vector`:: +Total number of vectors indexed. + +<> can affect this statistic. + -- end::index-metric[] diff --git a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/cluster.stats/10_basic.yml b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/cluster.stats/10_basic.yml index b38a03d53f89..0a3f9660da25 100644 --- a/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/cluster.stats/10_basic.yml +++ b/rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/cluster.stats/10_basic.yml @@ -238,8 +238,6 @@ indices.create: index: test1 body: - settings: - number_of_replicas: 0 mappings: properties: vector: @@ -257,8 +255,6 @@ indices.create: index: test2 body: - settings: - number_of_replicas: 0 mappings: properties: vector: diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIndices.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIndices.java index 20626f31e800..4e9c5bc551b6 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIndices.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/ClusterStatsIndices.java @@ -71,13 +71,13 @@ public ClusterStatsIndices( if (shardStats.getShardRouting().primary()) { indexShardStats.primaries++; docs.add(shardCommonStats.getDocs()); + denseVectorStats.add(shardCommonStats.getDenseVectorStats()); } store.add(shardCommonStats.getStore()); fieldData.add(shardCommonStats.getFieldData()); queryCache.add(shardCommonStats.getQueryCache()); completion.add(shardCommonStats.getCompletion()); segments.add(shardCommonStats.getSegments()); - denseVectorStats.add(shardCommonStats.getDenseVectorStats()); } searchUsageStats.add(r.searchUsageStats()); diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java index 8f26814def98..e2fb0573d724 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestShardsAction.java @@ -252,7 +252,7 @@ protected Table getTableWithHeader(final RestRequest request) { ); table.addCell( "dense_vector.value_count", - "alias:dvc,denseVectorCount;default:false;text-align:right;desc:total count of indexed dense vector" + "alias:dvc,denseVectorCount;default:false;text-align:right;desc:number of indexed dense vectors in shard" ); table.endHeaders();