Skip to content

Commit 9e3aad9

Browse files
committed
Add control for array size
1 parent 59a10bd commit 9e3aad9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

server/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.elasticsearch.common.xcontent.XContentHelper;
1818
import org.elasticsearch.core.Nullable;
1919
import org.elasticsearch.features.NodeFeature;
20+
import org.elasticsearch.index.IndexSettings;
2021
import org.elasticsearch.index.IndexVersion;
2122
import org.elasticsearch.index.IndexVersions;
2223
import org.elasticsearch.index.fielddata.FieldDataContext;
@@ -749,8 +750,14 @@ private static void parseNonDynamicArray(
749750
XContentParser.Token token;
750751
XContentParser.Token previousToken = parser.currentToken();
751752
int elements = 0;
753+
int countArray = 0;
754+
long nestedDocsLimit = context.indexSettings().getMappingNestedDocsLimit();
752755
while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) {
753756
if (token == XContentParser.Token.START_OBJECT) {
757+
if(countArray++ >= nestedDocsLimit) {
758+
throw new IllegalStateException("Limit [" + nestedDocsLimit + "] of elements in an array field [" + lastFieldName + "] " +
759+
"has been exceeded");
760+
}
754761
elements = 2;
755762
parseObject(context, lastFieldName);
756763
} else if (token == XContentParser.Token.START_ARRAY) {

0 commit comments

Comments
 (0)