diff --git a/core/src/main/java/org/elasticsearch/index/percolator/PercolatorFieldMapper.java b/core/src/main/java/org/elasticsearch/index/percolator/PercolatorFieldMapper.java index 07dbba79e91..0a993c63a35 100644 --- a/core/src/main/java/org/elasticsearch/index/percolator/PercolatorFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/percolator/PercolatorFieldMapper.java @@ -177,6 +177,9 @@ public class PercolatorFieldMapper extends FieldMapper { if (fieldMapper instanceof PercolatorFieldMapper) { PercolatorFieldType fieldType = (PercolatorFieldType) fieldMapper.fieldType(); if (context.doc().getField(fieldType.getQueryBuilderFieldName()) != null) { + // If a percolator query has been defined in an array object then multiple percolator queries + // could be provided. In order to prevent this we fail if we try to parse more than one query + // for the current document. throw new IllegalArgumentException("a document can only contain one percolator query"); } }