-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FastVectorHighlighter should not cache the field query globally (#25197)
This commit removes the global caching of the field query and replaces it with a caching per field. Each field can use a different `highlight_query` and the rewriting of some queries (prefix, automaton, ...) depends on the targeted field so the query used for highlighting must be unique per field. There might be a small performance penalty when highlighting multiple fields since the query needs to be rewritten once per highlighted field with this change. Fixes #25171
- Loading branch information
Showing
2 changed files
with
72 additions
and
25 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
49 changes: 49 additions & 0 deletions
49
rest-api-spec/src/main/resources/rest-api-spec/test/search.highlight/20_fvh.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,49 @@ | ||
setup: | ||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
mappings: | ||
doc: | ||
"properties": | ||
"title": | ||
"type": "text" | ||
"term_vector": "with_positions_offsets" | ||
"description": | ||
"type": "text" | ||
"term_vector": "with_positions_offsets" | ||
- do: | ||
index: | ||
index: test | ||
type: doc | ||
id: 1 | ||
body: | ||
"title" : "The quick brown fox is brown" | ||
"description" : "The quick pink panther is pink" | ||
- do: | ||
indices.refresh: {} | ||
|
||
--- | ||
"Highlight query": | ||
- skip: | ||
version: " - 5.5.99" | ||
reason: bug fixed in 5.6 | ||
- do: | ||
search: | ||
body: | ||
highlight: | ||
type: fvh | ||
fields: | ||
description: | ||
type: fvh | ||
highlight_query: | ||
prefix: | ||
description: br | ||
title: | ||
type: fvh | ||
highlight_query: | ||
prefix: | ||
title: br | ||
|
||
- match: {hits.hits.0.highlight.title.0: "The quick <em>brown</em> fox is <em>brown</em>"} | ||
- is_false: hits.hits.0.highlight.description |