forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Highlighters skip ignored keyword values (elastic#53408)
Keyword field values with length more than ignore_above are not indexed. But highlighters still were retrieving these values from _source and were trying to highlight them. This sometimes lead to errors if a field length exceeded max_analyzed_offset. But also this is an overall wrong behaviour to attempt to highlight something that was ignored during indexing. This PR checks if a keyword value was ignored because of its length, and if yes, skips highlighting it. Closes elastic#43800
- Loading branch information
1 parent
94da4ca
commit 5f7af83
Showing
5 changed files
with
101 additions
and
7 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
64 changes: 64 additions & 0 deletions
64
rest-api-spec/src/main/resources/rest-api-spec/test/search.highlight/40_keyword_ignore.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,64 @@ | ||
--- | ||
setup: | ||
- do: | ||
indices.create: | ||
index: test-index | ||
body: | ||
mappings: | ||
"properties": | ||
"k1": | ||
"type": "keyword" | ||
"k2": | ||
"type": "keyword" | ||
"ignore_above": 3 | ||
- do: | ||
bulk: | ||
index: test-index | ||
refresh: true | ||
body: | ||
- '{"index": {"_id": "1"}}' | ||
- '{"k1": "123", "k2" : "123"}' | ||
- '{"index": {"_id": "2"}}' | ||
- '{"k1": "1234", "k2" : "1234"}' | ||
|
||
--- | ||
"Plain Highligher should skip highlighting ignored keyword values": | ||
- skip: | ||
version: " - 7.6.99" | ||
reason: "skip highlighting of ignored values was introduced in 7.7" | ||
- do: | ||
search: | ||
index: test-index | ||
body: | ||
query: | ||
prefix: | ||
k1: "12" | ||
highlight: | ||
require_field_match: false | ||
fields: | ||
k2: | ||
type: plain | ||
|
||
- match: {hits.hits.0.highlight.k2.0: "<em>123</em>"} | ||
- is_false: hits.hits.1.highlight # no highlight for a value that was ignored | ||
|
||
--- | ||
"Unified Highligher should skip highlighting ignored keyword values": | ||
- skip: | ||
version: " - 7.6.99" | ||
reason: "skip highlighting of ignored values was introduced in 7.7" | ||
- do: | ||
search: | ||
index: test-index | ||
body: | ||
query: | ||
prefix: | ||
k1: "12" | ||
highlight: | ||
require_field_match: false | ||
fields: | ||
k2: | ||
type: unified | ||
|
||
- match: {hits.hits.0.highlight.k2.0: "<em>123</em>"} | ||
- is_false: hits.hits.1.highlight # no highlight for a value that was ignored |
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