File tree Expand file tree Collapse file tree 3 files changed +6
-3
lines changed
rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/search.highlight
main/java/org/elasticsearch/search/fetch/subphase/highlight
test/java/org/elasticsearch/search/fetch/subphase/highlight Expand file tree Collapse file tree 3 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ setup:
115115 - match : {hits.hits.0.highlight.field2.0: "The quick brown <em>fox</em> went to the forest and saw another fox."}
116116
117117---
118- " Plain highlighter with max_analyzed_offset < 0 should FAIL " :
118+ " Plain highlighter with max_analyzed_offset < -1 should FAIL " :
119119
120120 - requires :
121121 cluster_features : ["gte_v7.12.0"]
@@ -130,4 +130,4 @@ setup:
130130 - match : { status: 400 }
131131 - match : { error.root_cause.0.type: "x_content_parse_exception" }
132132 - match : { error.caused_by.type: "illegal_argument_exception" }
133- - match : { error.caused_by.reason: "[max_analyzed_offset] must be a positive integer" }
133+ - match : { error.caused_by.reason: "[max_analyzed_offset] must be an integer >= -1 " }
Original file line number Diff line number Diff line change @@ -565,6 +565,9 @@ public Integer phraseLimit() {
565565 */
566566 @ SuppressWarnings ("unchecked" )
567567 public HB maxAnalyzedOffset (Integer maxAnalyzedOffset ) {
568+ if (maxAnalyzedOffset != null && maxAnalyzedOffset < -1 ) {
569+ throw new IllegalArgumentException ("[" + MAX_ANALYZED_OFFSET_FIELD + "] must be an integer >= -1" );
570+ }
568571 this .maxAnalyzedOffset = maxAnalyzedOffset ;
569572 return (HB ) this ;
570573 }
Original file line number Diff line number Diff line change @@ -580,7 +580,7 @@ public void testInvalidMaxAnalyzedOffset() throws IOException {
580580 "{ \" max_analyzed_offset\" : " + randomIntBetween (-100 , 0 ) + "}"
581581 );
582582 assertThat (e .getMessage (), containsString ("[highlight] failed to parse field [" + MAX_ANALYZED_OFFSET_FIELD .toString () + "]" ));
583- assertThat (e .getCause ().getMessage (), containsString ("[max_analyzed_offset] must be a positive integer" ));
583+ assertThat (e .getCause ().getMessage (), containsString ("[max_analyzed_offset] must be an integer >= -1 " ));
584584 }
585585
586586 /**
You can’t perform that action at this time.
0 commit comments