-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Add a highlighter unit test base class #85719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Pinging @elastic/es-search (Team:Search) |
I've added one very basic unified highlighter test to this, but I think it might be worth trying to migrate some of our existing highlighter integration tests to use this base class instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@romseygeek Thanks Alan, this looks very nice and simplify our highlight tests a lot.
SearchSourceBuilder search = new SearchSourceBuilder().query(QueryBuilders.termQuery("field", "some")) | ||
.highlighter(new HighlightBuilder().field("field")); | ||
|
||
Map<String, HighlightField> highlights = highlight(mapperService, doc, search); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth to have even higher level abstraction, and provide a mapping and a document as Strings to highlight
method, and highlight
method itself inside create MapperService
and ParsedDocument
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did think about doing things that way, but I think this is slightly more flexible - it allows you to build mappings from XContent if you want to build something programmatically, for example. If it turns out that we're almost always using this pattern we can always add a sugar method that just takes strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explanation, Alan, makes sense.
* upstream/master: (40 commits) Fix BuildTests serialization (elastic#85827) Use urgent priority for node shutdown cluster state update (elastic#85838) Remove Task classes from HLRC (elastic#85835) Remove unused migration classes (elastic#85834) Remove uses of Charset name parsing (elastic#85795) Remove legacy versioned logic for DefaultSystemMemoryInfo (elastic#85761) Expose proxy settings for GCS repositories (elastic#85785) Remove SLM classes from HLRC (elastic#85825) TSDB: fix the time_series in order collect priority (elastic#85526) Remove ILM classes from HLRC (elastic#85822) FastVectorHighlighter should use ValueFetchers to load source data (elastic#85815) Iteratively execute synchronous ingest processors (elastic#84250) Remove TransformClient from HLRC (elastic#85787) Mute XPackRestIT deprecation/10_basic/Test Deprecations (elastic#85807) Unmute Lintian packaging test (elastic#85778) Add a highlighter unit test base class (elastic#85719) Remove NIO Transport Plugin (elastic#82085) [TEST] Remove token methods from HLRC SecurityClient (elastic#85515) [Test] Use thread-safe hashSet for result collection (elastic#85653) [TEST] Mute BuildTests.testSerialization (elastic#85801) ... # Conflicts: # server/src/test/java/org/elasticsearch/search/aggregations/timeseries/TimeSeriesIndexSearcherTests.java
The vast majority of our highlighter tests are integration or rest tests, which exercise the full ES stack but take a long time to run and are difficult to debug. We have a few unit tests but they are testing very low-level behaviour, and don't interact with the fetch phase or hit contexts. This commit adds a new HighlighterTestCase base class with some helper methods that should fill the gap between these two sets of tests. It includes a method that takes a MapperService, ParsedDocument and SearchSourceBuilder, and then runs the appropriate highlighter fetch subphase over the resulting hit.
The vast majority of our highlighter tests are integration or rest tests, which exercise the full ES stack but take a long time to run and are difficult to debug. We have a few unit tests but they are testing very low-level behaviour, and don't interact with the fetch phase or hit contexts. This commit adds a new HighlighterTestCase base class with some helper methods that should fill the gap between these two sets of tests. It includes a method that takes a MapperService, ParsedDocument and SearchSourceBuilder, and then runs the appropriate highlighter fetch subphase over the resulting hit.
The vast majority of our highlighter tests are integration or rest tests, which exercise
the full ES stack but take a long time to run and are difficult to debug. We have a few
unit tests but they are testing very low-level behaviour, and don't interact with the fetch
phase or hit contexts. This commit adds a new HighlighterTestCase base class with some
helper methods that should fill the gap between these two sets of tests. It includes a
method that takes a MapperService, ParsedDocument and SearchSourceBuilder, and then
runs the appropriate highlighter fetch subphase over the resulting hit.