diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 2b0044c3f6e..e06603cb38e 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -134,6 +134,9 @@ New Features
field must both be stored=false, indexed=false, docValues=true. (Ishan Chattopadhyaya, hossman, noble,
shalin, yonik)
+* SOLR-10158: Add support for "preload" option in MMapDirectoryFactory.
+ (Amrit Sarkar via Uwe Schindler)
+
Bug Fixes
----------------------
diff --git a/solr/core/src/java/org/apache/solr/core/MMapDirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/MMapDirectoryFactory.java
index c68ae62cf0e..e9fbce70619 100644
--- a/solr/core/src/java/org/apache/solr/core/MMapDirectoryFactory.java
+++ b/solr/core/src/java/org/apache/solr/core/MMapDirectoryFactory.java
@@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
* Can set the following parameters:
*
* - unmap -- See {@link MMapDirectory#setUseUnmap(boolean)}
+ * - preload -- See {@link MMapDirectory#setPreload(boolean)}
* - maxChunkSize -- The Max chunk size. See {@link MMapDirectory#MMapDirectory(Path, LockFactory, int)}
*
*
@@ -42,6 +43,7 @@ import org.slf4j.LoggerFactory;
public class MMapDirectoryFactory extends StandardDirectoryFactory {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
boolean unmapHack;
+ boolean preload;
private int maxChunk;
@Override
@@ -53,6 +55,7 @@ public class MMapDirectoryFactory extends StandardDirectoryFactory {
throw new IllegalArgumentException("maxChunk must be greater than 0");
}
unmapHack = params.getBool("unmap", true);
+ preload = params.getBool("preload", false); //default turn-off
}
@Override
@@ -64,6 +67,7 @@ public class MMapDirectoryFactory extends StandardDirectoryFactory {
} catch (IllegalArgumentException e) {
log.warn("Unmap not supported on this JVM, continuing on without setting unmap", e);
}
+ mapDirectory.setPreload(preload);
return mapDirectory;
}