|
@@ -19,6 +19,7 @@ import org.elasticsearch.common.Strings;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
|
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
|
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
|
|
|
|
|
+import org.elasticsearch.index.IndexSettings;
|
|
|
import org.elasticsearch.index.mapper.ConstantFieldType;
|
|
import org.elasticsearch.index.mapper.ConstantFieldType;
|
|
|
import org.elasticsearch.index.mapper.MappedFieldType;
|
|
import org.elasticsearch.index.mapper.MappedFieldType;
|
|
|
import org.elasticsearch.index.query.support.QueryParsers;
|
|
import org.elasticsearch.index.query.support.QueryParsers;
|
|
@@ -209,6 +210,20 @@ public class PrefixQueryBuilder extends AbstractQueryBuilder<PrefixQueryBuilder>
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
protected Query doToQuery(SearchExecutionContext context) throws IOException {
|
|
protected Query doToQuery(SearchExecutionContext context) throws IOException {
|
|
|
|
|
+ final int maxAllowedRegexLength = context.getIndexSettings().getMaxRegexLength();
|
|
|
|
|
+ if (value.length() > maxAllowedRegexLength) {
|
|
|
|
|
+ throw new IllegalArgumentException(
|
|
|
|
|
+ "The length of prefix ["
|
|
|
|
|
+ + value.length()
|
|
|
|
|
+ + "] used in the Prefix Query request has exceeded "
|
|
|
|
|
+ + "the allowed maximum of ["
|
|
|
|
|
+ + maxAllowedRegexLength
|
|
|
|
|
+ + "]. "
|
|
|
|
|
+ + "This maximum can be set by changing the ["
|
|
|
|
|
+ + IndexSettings.MAX_REGEX_LENGTH_SETTING.getKey()
|
|
|
|
|
+ + "] index level setting."
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod(rewrite, null, LoggingDeprecationHandler.INSTANCE);
|
|
MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod(rewrite, null, LoggingDeprecationHandler.INSTANCE);
|
|
|
|
|
|
|
|
MappedFieldType fieldType = context.getFieldType(fieldName);
|
|
MappedFieldType fieldType = context.getFieldType(fieldName);
|