-
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.
Fix regressions around nested hits and disabled _source. (#66572)
This PR fixes two bugs that can arise when _source is disabled and we fetch nested documents: * Fix exception when highlighting `inner_hits` with disabled _source. * Fix exception in nested `top_hits` with disabled _source. * Add more tests for highlighting `inner_hits`.
- Loading branch information
1 parent
445c850
commit c013239
Showing
3 changed files
with
196 additions
and
6 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
137 changes: 137 additions & 0 deletions
137
rest-api-spec/src/main/resources/rest-api-spec/test/search.inner_hits/20_highlighting.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,137 @@ | ||
setup: | ||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
mappings: | ||
_source: | ||
excludes: ["nested.stored_only"] | ||
properties: | ||
nested: | ||
type: nested | ||
properties: | ||
field: | ||
type: text | ||
fields: | ||
vectors: | ||
type: text | ||
term_vector: "with_positions_offsets" | ||
postings: | ||
type: text | ||
index_options: "offsets" | ||
stored: | ||
type: text | ||
store: true | ||
stored_only: | ||
type: text | ||
store: true | ||
- do: | ||
index: | ||
index: test | ||
id: 1 | ||
refresh: true | ||
body: | ||
nested: | ||
field : "The quick brown fox is brown." | ||
stored : "The quick brown fox is brown." | ||
stored_only : "The quick brown fox is brown." | ||
|
||
--- | ||
"Unified highlighter": | ||
- do: | ||
search: | ||
index: test | ||
body: | ||
query: | ||
nested: | ||
path: "nested" | ||
query: | ||
multi_match: | ||
query: "quick brown fox" | ||
fields: [ "nested.field", "nested.field.vectors", "nested.field.postings" ] | ||
inner_hits: | ||
highlight: | ||
type: "unified" | ||
fields: | ||
nested.field: {} | ||
nested.field.vectors: {} | ||
nested.field.postings: {} | ||
|
||
- match: { hits.hits.0.inner_hits.nested.hits.hits.0.highlight.nested\.field.0: "The <em>quick</em> <em>brown</em> <em>fox</em> is <em>brown</em>." } | ||
- match: { hits.hits.0.inner_hits.nested.hits.hits.0.highlight.nested\.field\.vectors.0: "The <em>quick</em> <em>brown</em> <em>fox</em> is <em>brown</em>." } | ||
- match: { hits.hits.0.inner_hits.nested.hits.hits.0.highlight.nested\.field\.postings.0: "The <em>quick</em> <em>brown</em> <em>fox</em> is <em>brown</em>." } | ||
|
||
--- | ||
"Unified highlighter with stored fields": | ||
- do: | ||
search: | ||
index: test | ||
body: | ||
query: | ||
nested: | ||
path: "nested" | ||
query: | ||
multi_match: | ||
query: "quick brown fox" | ||
fields: [ "nested.stored", "nested.stored_only" ] | ||
inner_hits: | ||
highlight: | ||
type: "unified" | ||
fields: | ||
nested.stored: {} | ||
nested.stored_only: {} | ||
|
||
- match: { hits.hits.0.inner_hits.nested.hits.hits.0.highlight.nested\.stored.0: "The <em>quick</em> <em>brown</em> <em>fox</em> is <em>brown</em>." } | ||
- match: { hits.hits.0.inner_hits.nested.hits.hits.0.highlight.nested\.stored_only.0: "The <em>quick</em> <em>brown</em> <em>fox</em> is <em>brown</em>." } | ||
|
||
--- | ||
"Unified highlighter with stored fields and disabled source": | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: "bug fix is not yet backported" | ||
- do: | ||
indices.create: | ||
index: disabled_source | ||
body: | ||
mappings: | ||
_source: | ||
enabled: false | ||
properties: | ||
nested: | ||
type: nested | ||
properties: | ||
field: | ||
type: text | ||
stored_only: | ||
type: text | ||
store: true | ||
- do: | ||
index: | ||
index: disabled_source | ||
id: 1 | ||
refresh: true | ||
body: | ||
nested: | ||
field: "The quick brown fox is brown." | ||
stored_only: "The quick brown fox is brown." | ||
|
||
- do: | ||
search: | ||
index: disabled_source | ||
body: | ||
query: | ||
nested: | ||
path: "nested" | ||
query: | ||
multi_match: | ||
query: "quick brown fox" | ||
fields: ["nested.field", "nested.stored_only"] | ||
inner_hits: | ||
highlight: | ||
type: "unified" | ||
fields: | ||
nested.field: {} | ||
nested.stored_only: {} | ||
|
||
- is_false: hits.hits.0.inner_hits.nested.hits.hits.0.highlight.nested\.field | ||
- match: { hits.hits.0.inner_hits.nested.hits.hits.0.highlight.nested\.stored_only.0: "The <em>quick</em> <em>brown</em> <em>fox</em> is <em>brown</em>."} |
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