forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FastVectorHighlighter should use ValueFetchers to load source data (e…
…lastic#85815) FVH was relying on `SourceLookup.extractRawValues()` to load its data, but this no longer works for multifields. It should instead use value fetchers which will correctly locate the input for multifields and/or copy fields. Fixes elastic#84690 Fixes elastic#82458 Fixes elastic#80895 Fixes elastic#75011
- Loading branch information
1 parent
cce3d92
commit a69cdd0
Showing
7 changed files
with
99 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
pr: 85815 | ||
summary: '`FastVectorHighlighter` should use `ValueFetchers` to load source data' | ||
area: Highlighting | ||
type: bug | ||
issues: | ||
- 75011 | ||
- 84690 | ||
- 82458 | ||
- 80895 |
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
68 changes: 68 additions & 0 deletions
68
...st/java/org/elasticsearch/search/fetch/subphase/highlight/FastVectorHighlighterTests.java
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,68 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.search.fetch.subphase.highlight; | ||
|
||
import org.elasticsearch.index.mapper.MapperService; | ||
import org.elasticsearch.index.mapper.ParsedDocument; | ||
import org.elasticsearch.index.query.QueryBuilders; | ||
import org.elasticsearch.search.builder.SearchSourceBuilder; | ||
import org.elasticsearch.search.fetch.HighlighterTestCase; | ||
|
||
import java.io.IOException; | ||
|
||
public class FastVectorHighlighterTests extends HighlighterTestCase { | ||
|
||
public void testHighlightingMultiFields() throws IOException { | ||
|
||
MapperService mapperService = createMapperService(""" | ||
{ "_doc" : { "properties" : { | ||
"field" : { | ||
"type" : "text", | ||
"fields" : { | ||
"stemmed" : { | ||
"type" : "text", | ||
"term_vector" : "with_positions_offsets" | ||
} | ||
} | ||
} | ||
}}} | ||
"""); | ||
|
||
ParsedDocument doc = mapperService.documentMapper().parse(source(""" | ||
{ "field" : "here is some text, which is followed by some more text" } | ||
""")); | ||
|
||
{ | ||
// test SimpleFragmentsBuilder case | ||
SearchSourceBuilder search = new SearchSourceBuilder().query(QueryBuilders.termQuery("field.stemmed", "some")) | ||
.highlighter(new HighlightBuilder().field("field.stemmed").highlighterType("fvh")); | ||
|
||
assertHighlights( | ||
highlight(mapperService, doc, search), | ||
"field.stemmed", | ||
"here is <em>some</em> text, which is followed by <em>some</em> more text" | ||
); | ||
} | ||
|
||
{ | ||
// test ScoreOrderFragmentsBuilder case | ||
SearchSourceBuilder search = new SearchSourceBuilder().query(QueryBuilders.termQuery("field.stemmed", "some")) | ||
.highlighter(new HighlightBuilder().field("field.stemmed").highlighterType("fvh").numOfFragments(2).fragmentSize(18)); | ||
|
||
assertHighlights( | ||
highlight(mapperService, doc, search), | ||
"field.stemmed", | ||
"here is <em>some</em> text, which", | ||
"followed by <em>some</em> more text" | ||
); | ||
} | ||
|
||
} | ||
|
||
} |
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