Skip to content

Commit 09a81e0

Browse files
committed
Add instructions for index upgrade in SolrCloud mode (#4424)
The UPGRADEINDEX API is currently only available in standalone mode as a CoreAdmin API. However, it is possible to achieve the same goal (i.e. upgrade the index in-place for future Solr major version upgrade) in SolrCloud with the recently introduced LatestVersionMergePolicyFactory. This commit details the steps for the same. (cherry picked from commit 3039f30)
1 parent 19c2f56 commit 09a81e0

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

solr/solr-ref-guide/modules/configuration-guide/pages/coreadmin-api.adoc

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ Note:
792792

793793
* Only stored fields and fields with docValues enabled can be preserved during upgrade.
794794
Fields that are neither stored nor docValues-backed will lose their data, unless they are `copyField` targets.
795-
* Not supported in SolrCloud mode. In order to achieve the same purpose in SolrCloud mode (aka upgrade index for compatibility with next Solr version), configure the `LatestVersionMergePolicyFactory` for the collection and reindex all documents through a client utility.
795+
* Not supported in SolrCloud mode; see <<Upgrading an Index in SolrCloud Mode>> below for the equivalent procedure.
796796
* Indexes containing child/nested documents are not supported.
797797

798798
It is recommended to test on a copy and have a backup before running on production data.
@@ -868,6 +868,36 @@ Then poll status:
868868
http://localhost:8983/solr/admin/cores?action=REQUESTSTATUS&requestid=upgrade_1
869869
----
870870

871+
=== Upgrading an Index in SolrCloud Mode
872+
873+
Currently, a corresponding Collections API `UPGRADEINDEX` action for SolrCloud is not available.
874+
However, the equivalent goal -- making the index compatible with the next Solr major version -- can be achieved by reindexing all documents while `LatestVersionMergePolicyFactory` is the active merge policy on the collection.
875+
876+
The procedure below avoids reprocessing documents that have already been reindexed, including across restarts:
877+
878+
. *Prepare a configset that uses `LatestVersionMergePolicyFactory`.*
879+
Copy the collection's current xref:config-sets.adoc[configset] so the original is not modified, and edit `solrconfig.xml` in the copy to set the xref:index-segments-merging.adoc#mergepolicyfactory[`<mergePolicyFactory>`] to `org.apache.solr.index.LatestVersionMergePolicyFactory`.
880+
. *Point the collection at the new configset.*
881+
Use the xref:deployment-guide:collection-management.adoc#modifycollection[MODIFYCOLLECTION] Collections API action to set the `collection.configName` property to the name of the new configset.
882+
. *Reload the collection* with the xref:deployment-guide:collection-management.adoc#reload[RELOAD] Collections API action so the new merge policy takes effect.
883+
. *Record the current highest `\_version_` value in the index.*
884+
Query the collection sorting by `\_version_` descending and note the top value, for example:
885+
+
886+
[source,bash]
887+
----
888+
http://localhost:8983/solr/_collection_/select?q=*:*&sort=_version_+desc&rows=1&fl=_version_
889+
----
890+
. *Reindex only the documents at or below that version.*
891+
Have your client reindex all docs where `\_version_ \<= <highest_version>` (substituting the recorded value).
892+
+
893+
Reusing the same `<highest_version>` value across restarts ensures continuity: Documents that have already been reindexed -- as well as any newly indexed documents -- will have a `\_version_` greater than the recorded value and will fall outside the range, so no work is duplicated.
894+
. *Issue a commit once reindexing is complete* to clear any older version segments:
895+
+
896+
[source,bash]
897+
----
898+
http://localhost:8983/solr/_collection_/update?commit=true
899+
----
900+
871901
[[coreadmin-requeststatus]]
872902
== REQUESTSTATUS
873903

0 commit comments

Comments
 (0)