From e74ae3f1951e442acfc8478650c9e301ac1c3e86 Mon Sep 17 00:00:00 2001 From: fabrizzio-dotCMS Date: Mon, 13 Jul 2026 15:03:00 -0600 Subject: [PATCH] fix(os-index): resolve getIndexDocumentCount physical name via the read provider (.os tag) (#36501) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ContentletIndexAPIImpl.getIndexDocumentCount(String) resolved the physical index name with indexAPI.getNameWithClusterIDPrefix(indexName), which adds the cluster prefix but NOT the .os tag. Under migration phase 2/3 the read provider is OpenSearch, whose indices are .os-tagged, so the lookup hit a non-existent index ("no such index [cluster_....working_...]" without the .os suffix) and threw. Resolve the physical name through the read provider's own toPhysicalName() — which adds the cluster prefix for ES and the prefix + .os tag for OS — mirroring the sibling getIndexDocumentCount(String, IndexTag) overload. (Fixes ContentletIndexAPIImplTest.testGetIndexDocumentCountSuccess under phase 2.) Co-Authored-By: Claude Opus 4.8 (1M context) --- .../elasticsearch/business/ContentletIndexAPIImpl.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ContentletIndexAPIImpl.java b/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ContentletIndexAPIImpl.java index cb675e4d76f..e4a562ac09d 100644 --- a/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ContentletIndexAPIImpl.java +++ b/dotCMS/src/main/java/com/dotcms/content/elasticsearch/business/ContentletIndexAPIImpl.java @@ -3264,8 +3264,11 @@ private void mirrorDeactivateToOsStore(final String indexName) throws DotDataExc */ @Override public long getIndexDocumentCount(final String indexName) { - return router.readProvider().getIndexDocumentCount( - indexAPI.getNameWithClusterIDPrefix(indexName)); + // Resolve the physical name through the read provider's own toPhysicalName so the OS read + // path (phases 2/3) receives the .os-tagged name. getNameWithClusterIDPrefix adds only the + // cluster prefix (no .os tag), so under OS reads the index was reported as not found. + final ContentletIndexOperations readProvider = router.readProvider(); + return readProvider.getIndexDocumentCount(readProvider.toPhysicalName(indexName)); } /**