-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Limit the analyzed text for highlighting (#27934)
* Limit the analyzed text for highlighting - Introduce index level settings to control the max number of character to be analyzed for highlighting - Throw an error if analysis is required on a larger text Closes #27517
- Loading branch information
1 parent
d63b1ef
commit cbd271e
Showing
10 changed files
with
153 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...pi-spec/src/main/resources/rest-api-spec/test/search.highlight/30_max_analyzed_offset.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
--- | ||
setup: | ||
- do: | ||
indices.create: | ||
index: test1 | ||
body: | ||
settings: | ||
number_of_shards: 1 | ||
index.highlight.max_analyzed_offset: 10 | ||
mappings: | ||
test_type: | ||
properties: | ||
field1: | ||
type: text | ||
field2: | ||
type: text | ||
index_options: offsets | ||
|
||
- do: | ||
index: | ||
index: test1 | ||
type: test_type | ||
id: 1 | ||
body: | ||
"field1" : "The quick brown fox went to the forest and saw another fox." | ||
"field2" : "The quick brown fox went to the forest and saw another fox." | ||
|
||
- do: | ||
indices.refresh: {} | ||
|
||
--- | ||
"Unified highlighter on a field WITHOUT OFFSETS exceeding index.highlight.max_analyzed_offset should FAIL": | ||
- skip: | ||
version: " - 6.99.99" | ||
reason: index.highlight.max_analyzed_offset setting has been added in 7.0.0 | ||
- do: | ||
catch: bad_request | ||
search: | ||
index: test1 | ||
body: {"query" : {"match" : {"field1" : "fox"}}, "highlight" : {"type" : "unified", "fields" : {"field1" : {}}}} | ||
- match: { error.root_cause.0.type: "illegal_argument_exception" } | ||
|
||
|
||
--- | ||
"Plain highlighter on a field WITHOUT OFFSETS exceeding index.highlight.max_analyzed_offset should FAIL": | ||
- skip: | ||
version: " - 6.99.99" | ||
reason: index.highlight.max_analyzed_offset setting has been added in 7.0.0 | ||
- do: | ||
catch: bad_request | ||
search: | ||
index: test1 | ||
body: {"query" : {"match" : {"field1" : "fox"}}, "highlight" : {"type" : "unified", "fields" : {"field1" : {}}}} | ||
- match: { error.root_cause.0.type: "illegal_argument_exception" } | ||
|
||
|
||
--- | ||
"Unified highlighter on a field WITH OFFSETS exceeding index.highlight.max_analyzed_offset should SUCCEED": | ||
- skip: | ||
version: " - 6.99.99" | ||
reason: index.highligt.max_analyzed_offset setting has been added in 7.0.0 | ||
- do: | ||
search: | ||
index: test1 | ||
body: {"query" : {"match" : {"field2" : "fox"}}, "highlight" : {"type" : "unified", "fields" : {"field2" : {}}}} | ||
- match: {hits.hits.0.highlight.field2.0: "The quick brown <em>fox</em> went to the forest and saw another <em>fox</em>."} | ||
|
||
|
||
--- | ||
"Plain highlighter on a field WITH OFFSETS exceeding index.highlight.max_analyzed_offset should FAIL": | ||
- skip: | ||
version: " - 6.99.99" | ||
reason: index.highlight.max_analyzed_offset setting has been added in 7.0.0 | ||
- do: | ||
catch: bad_request | ||
search: | ||
index: test1 | ||
body: {"query" : {"match" : {"field2" : "fox"}}, "highlight" : {"type" : "plain", "fields" : {"field2" : {}}}} | ||
- match: { error.root_cause.0.type: "illegal_argument_exception" } |