From da20003d4f00a05fa608bbf442766b716c8c851a Mon Sep 17 00:00:00 2001
From: Maxim Thomas <maxim.thomas@gmail.com>
Date: Tue, 25 Mar 2025 13:28:33 +0000
Subject: [PATCH] [#497] Set the same indexes for a new backend as for the initial backend (#501)

---
 opendj-server-legacy/src/main/java/org/opends/server/tools/BackendCreationHelper.java                                  |   18 +++++----
 opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/PluggableBackendConfiguration.xml |   71 +++++++++++++++++++++++++++++++++++
 opendj-doc-generated-ref/src/main/asciidoc/admin-guide/chap-indexing.adoc                                              |   10 +---
 opendj-doc-generated-ref/src/main/asciidoc/admin-guide/chap-import-export.adoc                                         |    9 ++++
 4 files changed, 93 insertions(+), 15 deletions(-)

diff --git a/opendj-doc-generated-ref/src/main/asciidoc/admin-guide/chap-import-export.adoc b/opendj-doc-generated-ref/src/main/asciidoc/admin-guide/chap-import-export.adoc
index 6233cb5..c96922b 100644
--- a/opendj-doc-generated-ref/src/main/asciidoc/admin-guide/chap-import-export.adoc
+++ b/opendj-doc-generated-ref/src/main/asciidoc/admin-guide/chap-import-export.adoc
@@ -352,10 +352,19 @@
 When you create a new backend using the `dsconfig` command, OpenDJ directory server creates the following indexes automatically:
 [none]
 * `aci` presence
+* `cn` equality, substring
 * `ds-sync-conflict` equality
 * `ds-sync-hist` ordering
 * `entryUUID` equality
 * `objectClass` equality
+* `givenName` equality, substring
+* `mail`  equality, substring
+* `member` equality
+* `sn` equality, substring
+* `telephoneNumber` equality, substring
+* `uid` equality
+* `uniqueMember` equality
+
 You can create additional indexes as described in xref:../admin-guide/chap-indexing.adoc#configure-indexes["Configuring and Rebuilding Indexes"].
 
 
diff --git a/opendj-doc-generated-ref/src/main/asciidoc/admin-guide/chap-indexing.adoc b/opendj-doc-generated-ref/src/main/asciidoc/admin-guide/chap-indexing.adoc
index 79cf275..6206f0e 100644
--- a/opendj-doc-generated-ref/src/main/asciidoc/admin-guide/chap-indexing.adoc
+++ b/opendj-doc-generated-ref/src/main/asciidoc/admin-guide/chap-indexing.adoc
@@ -1101,13 +1101,9 @@
 a|-
 a|4000
 |===
-When you create a new backend using the `dsconfig` command, OpenDJ directory server creates the following indexes automatically:
-[none]
-* `aci` presence
-* `ds-sync-conflict` equality
-* `ds-sync-hist` ordering
-* `entryUUID` equality
-* `objectClass` equality
+
+When you create a new backend using the `dsconfig` command, the OpenDJ Directory Server also automatically creates these indexes.
+
 You can create additional indexes as described in xref:../admin-guide/chap-indexing.adoc#configure-indexes["Configuring and Rebuilding Indexes"].
 
 
diff --git a/opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/PluggableBackendConfiguration.xml b/opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/PluggableBackendConfiguration.xml
index 9ceb3e4..0d1f70d 100644
--- a/opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/PluggableBackendConfiguration.xml
+++ b/opendj-maven-plugin/src/main/resources/config/xml/org/forgerock/opendj/server/config/PluggableBackendConfiguration.xml
@@ -71,6 +71,77 @@
           <adm:value>ds-sync-conflict</adm:value>
         </adm:property>
       </adm:default-managed-object>
+
+      <adm:default-managed-object name="cn">
+        <adm:property name="index-type">
+          <adm:value>equality</adm:value>
+          <adm:value>substring</adm:value>
+        </adm:property>
+        <adm:property name="attribute">
+          <adm:value>cn</adm:value>
+        </adm:property>
+      </adm:default-managed-object>
+      <adm:default-managed-object name="givenName">
+        <adm:property name="index-type">
+          <adm:value>equality</adm:value>
+          <adm:value>substring</adm:value>
+        </adm:property>
+        <adm:property name="attribute">
+          <adm:value>givenName</adm:value>
+        </adm:property>
+      </adm:default-managed-object>
+      <adm:default-managed-object name="mail">
+        <adm:property name="index-type">
+          <adm:value>equality</adm:value>
+          <adm:value>substring</adm:value>
+        </adm:property>
+        <adm:property name="attribute">
+          <adm:value>mail</adm:value>
+        </adm:property>
+      </adm:default-managed-object>
+      <adm:default-managed-object name="sn">
+        <adm:property name="index-type">
+          <adm:value>equality</adm:value>
+          <adm:value>substring</adm:value>
+        </adm:property>
+        <adm:property name="attribute">
+          <adm:value>sn</adm:value>
+        </adm:property>
+      </adm:default-managed-object>
+      <adm:default-managed-object name="telephoneNumber">
+        <adm:property name="index-type">
+          <adm:value>equality</adm:value>
+          <adm:value>substring</adm:value>
+        </adm:property>
+        <adm:property name="attribute">
+          <adm:value>telephoneNumber</adm:value>
+        </adm:property>
+      </adm:default-managed-object>
+      <adm:default-managed-object name="member">
+        <adm:property name="index-type">
+          <adm:value>equality</adm:value>
+        </adm:property>
+        <adm:property name="attribute">
+          <adm:value>member</adm:value>
+        </adm:property>
+      </adm:default-managed-object>
+      <adm:default-managed-object name="uid">
+        <adm:property name="index-type">
+          <adm:value>equality</adm:value>
+        </adm:property>
+        <adm:property name="attribute">
+          <adm:value>uid</adm:value>
+        </adm:property>
+      </adm:default-managed-object>
+      <adm:default-managed-object name="uniqueMember">
+        <adm:property name="index-type">
+          <adm:value>equality</adm:value>
+        </adm:property>
+        <adm:property name="attribute">
+          <adm:value>uniqueMember</adm:value>
+        </adm:property>
+      </adm:default-managed-object>
+
     </adm:one-to-many>
     <adm:profile name="ldap">
       <ldap:rdn-sequence>cn=Index</ldap:rdn-sequence>
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/BackendCreationHelper.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/BackendCreationHelper.java
index 7696218..1cbb46e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/BackendCreationHelper.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/BackendCreationHelper.java
@@ -98,14 +98,16 @@
 
   /** Default indexes to add in a new backend. */
   public static final CreateIndex[] DEFAULT_INDEXES = {
-    CreateIndex.withEqualityAndSubstring("cn"),
-    CreateIndex.withEqualityAndSubstring("givenName"),
-    CreateIndex.withEqualityAndSubstring("mail"),
-    CreateIndex.withEqualityAndSubstring("sn"),
-    CreateIndex.withEqualityAndSubstring("telephoneNumber"),
-    CreateIndex.withEquality("member"),
-    CreateIndex.withEquality("uid"),
-    CreateIndex.withEquality("uniqueMember")
+// Default indexes moved to the PluggableBackendConfiguration.xml file,
+// see https://github.com/OpenIdentityPlatform/OpenDJ/issues/497
+//    CreateIndex.withEqualityAndSubstring("cn"),
+//    CreateIndex.withEqualityAndSubstring("givenName"),
+//    CreateIndex.withEqualityAndSubstring("mail"),
+//    CreateIndex.withEqualityAndSubstring("sn"),
+//    CreateIndex.withEqualityAndSubstring("telephoneNumber"),
+//    CreateIndex.withEquality("member"),
+//    CreateIndex.withEquality("uid"),
+//    CreateIndex.withEquality("uniqueMember")
   };
 
   /**

--
Gitblit v1.10.0