@@ -209,6 +209,14 @@ public final class IndexSettings {
209209 Property .IndexScope
210210 );
211211
212+ public static final Setting <Integer > MAX_SOURCE_SIZE_BYTES_SETTING = Setting .intSetting (
213+ "index.max_source_size_bytes" ,
214+ 500000 ,
215+ 1 ,
216+ Property .Dynamic ,
217+ Property .IndexScope
218+ );
219+
212220 /**
213221 * Index setting describing the maximum number of terms that can be used in Terms Query.
214222 * The default maximum of 65536 terms is defensive, as extra processing and memory is involved
@@ -919,6 +927,7 @@ private void setRetentionLeaseMillis(final TimeValue retentionLease) {
919927 private volatile TimeValue searchIdleAfter ;
920928 private volatile int maxAnalyzedOffset ;
921929 private volatile boolean weightMatchesEnabled ;
930+ private volatile int maxSourceSizeBytes ;
922931 private volatile int maxTermsCount ;
923932 private volatile String defaultPipeline ;
924933 private volatile String requiredPipeline ;
@@ -1091,6 +1100,7 @@ public IndexSettings(final IndexMetadata indexMetadata, final Settings nodeSetti
10911100 maxSlicesPerScroll = scopedSettings .get (MAX_SLICES_PER_SCROLL );
10921101 maxAnalyzedOffset = scopedSettings .get (MAX_ANALYZED_OFFSET_SETTING );
10931102 weightMatchesEnabled = scopedSettings .get (WEIGHT_MATCHES_MODE_ENABLED_SETTING );
1103+ maxSourceSizeBytes = scopedSettings .get (MAX_SOURCE_SIZE_BYTES_SETTING );
10941104 maxTermsCount = scopedSettings .get (MAX_TERMS_COUNT_SETTING );
10951105 maxRegexLength = scopedSettings .get (MAX_REGEX_LENGTH_SETTING );
10961106 this .mergePolicyConfig = new MergePolicyConfig (logger , this );
@@ -1202,6 +1212,7 @@ public IndexSettings(final IndexMetadata indexMetadata, final Settings nodeSetti
12021212 scopedSettings .addSettingsUpdateConsumer (MAX_REFRESH_LISTENERS_PER_SHARD , this ::setMaxRefreshListeners );
12031213 scopedSettings .addSettingsUpdateConsumer (MAX_ANALYZED_OFFSET_SETTING , this ::setHighlightMaxAnalyzedOffset );
12041214 scopedSettings .addSettingsUpdateConsumer (WEIGHT_MATCHES_MODE_ENABLED_SETTING , this ::setWeightMatchesEnabled );
1215+ scopedSettings .addSettingsUpdateConsumer (MAX_SOURCE_SIZE_BYTES_SETTING , this ::setMaxSourceSizeBytes );
12051216 scopedSettings .addSettingsUpdateConsumer (MAX_TERMS_COUNT_SETTING , this ::setMaxTermsCount );
12061217 scopedSettings .addSettingsUpdateConsumer (MAX_SLICES_PER_SCROLL , this ::setMaxSlicesPerScroll );
12071218 scopedSettings .addSettingsUpdateConsumer (DEFAULT_FIELD_SETTING , this ::setDefaultFields );
@@ -1603,6 +1614,17 @@ private void setWeightMatchesEnabled(boolean value) {
16031614 this .weightMatchesEnabled = value ;
16041615 }
16051616
1617+ /**
1618+ * Returns the maximum number of terms that can be used in a Terms Query request
1619+ */
1620+ public int getMaxSourceSizeBytes () {
1621+ return this .maxSourceSizeBytes ;
1622+ }
1623+
1624+ private void setMaxSourceSizeBytes (int maxSourceSizeBytes ) {
1625+ this .maxSourceSizeBytes = maxSourceSizeBytes ;
1626+ }
1627+
16061628 /**
16071629 * Returns the maximum number of terms that can be used in a Terms Query request
16081630 */
0 commit comments