{"record":{"id":"3f0a53789e9c9921","repo":"phacility/phabricator","slug":"failed-to-rebuild-search-index-for-any-documents","errorCode":null,"errorMessage":"Failed to rebuild search index for any documents.","messagePattern":"Failed to rebuild search index for any documents\\.","errorType":"console","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/search/management/PhabricatorSearchManagementIndexWorkflow.php","lineNumber":258,"sourceCode":"          } else if ($old_versions !== $new_versions) {\n            $count_updated++;\n          } else {\n            $count_skipped++;\n          }\n        }\n\n        $any_success = true;\n      } catch (Exception $ex) {\n        phlog($ex);\n      }\n\n      $bar->update(1);\n    }\n\n    $bar->done();\n\n    if (!$any_success) {\n      throw new Exception(\n        pht('Failed to rebuild search index for any documents.'));\n    }\n\n    if ($track_skips) {\n      if ($count_updated) {\n        $this->logOkay(\n          pht('DONE'),\n          pht(\n            'Updated search indexes for %s document(s).',\n            new PhutilNumber($count_updated)));\n      }\n\n      if ($count_skipped) {\n        $this->logWarn(\n          pht('SKIP'),\n          pht(\n            'Skipped %s documents(s) which have not updated since they were '.\n            'last indexed.',","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/search/management/PhabricatorSearchManagementIndexWorkflow.php#L240-L276","documentation":"Thrown by `bin/search index` after iterating all selected documents: not a single document reindexed successfully ($any_success stayed false). Each per-document failure was caught and logged with phlog(), so the real exceptions appear earlier in output. This is an aggregate signal that the search backend is rejecting or failing every write, not a problem with one object.","triggerScenarios":"`bin/search index --all` (or any selector) when the configured search service is down or misconfigured, the Elasticsearch index/mappings are missing or incompatible (e.g. after an ES upgrade without re-init), writes return 4xx/5xx for every document, or every selected object raises during indexing.","commonSituations":"Elasticsearch stopped or unreachable; cluster.search misconfigured (see the invalid-JSON error); index deleted or never initialized after switching engines; ES upgraded and mapping types no longer accepted; ES node out of disk (flood-stage blocks writes); running reindex before the search service started.","solutions":["Scroll up in the output and read the phlog'd per-document exceptions - they carry the root cause","Run `bin/search status` to confirm every configured host is healthy","Check ES cluster health and disk watermarks: curl http://host:9200/_cluster/health","If indices are stale or mappings are incompatible, reinitialize the index (bin/search init in this workflow family) and then reindex","Smoke-test with one document first: `bin/search index D1`"],"exampleFix":"# before: mass reindex with a broken backend\nbin/search index --all\n\n# after: verify, smoke-test one document, then bulk\nbin/search status\nbin/search index D1\nbin/search index --all","handlingStrategy":"try-catch","validationCode":"// Preflight the backend before any bulk reindex\nexec('./bin/search status', $output, $code);\nif ($code !== 0) {\n  // fix the search service before reindexing\n}","typeGuard":null,"tryCatchPattern":"try {\n  $workflow->execute($args); // reindex selected documents\n} catch (Exception $ex) {\n  if (strpos($ex->getMessage(), 'Failed to rebuild search index') === 0) {\n    // zero documents succeeded: inspect phlog'd per-document exceptions,\n    // repair the backend, then retry from the first document\n  }\n}","preventionTips":["Run bin/search status before any bulk reindex","Smoke-test one document (bin/search index D1) before --all","Watch Elasticsearch cluster health and disk watermarks","Recreate indices after ES upgrades so mappings match the indexer"],"tags":["search","reindex","elasticsearch","aggregate-failure","bin-search"],"backgroundTag":"index-rebuild-failed","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}