Skip to content

Commit

Permalink
Fix cluster level dense vector stats
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jimczi committed Apr 26, 2024
1 parent d7e524f commit ceefe24
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion docs/reference/cluster/stats.asciidoc
Expand Up @@ -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.
=====
====

Expand Down
6 changes: 6 additions & 0 deletions docs/reference/rest-api/common-parms.asciidoc
Expand Up @@ -556,6 +556,12 @@ Size of the index in <<byte-units, byte units>>.

`translog`::
<<index-modules-translog,Translog>> statistics.

`dense_vector`::
Total number of vectors indexed.

<<indices-refresh,Index refreshes>> can affect this statistic.

--
end::index-metric[]

Expand Down
Expand Up @@ -238,8 +238,6 @@
indices.create:
index: test1
body:
settings:
number_of_replicas: 0
mappings:
properties:
vector:
Expand All @@ -257,8 +255,6 @@
indices.create:
index: test2
body:
settings:
number_of_replicas: 0
mappings:
properties:
vector:
Expand Down
Expand Up @@ -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());
Expand Down
Expand Up @@ -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();
Expand Down

0 comments on commit ceefe24

Please sign in to comment.