It's currently extremely hard to control the highlighting behaviors of search:
- only few keywords have dedicated support for highlighting
- it's too hard for query builders to include additional data fetched from elastic
We should provide a fluent building process so that query building components can control the behavior of highlighting.
The ResultsType should not be decided too early.
Query components should declare:
- the target output they want to populate:
- standard ones: titleSnippet, textSnippet, redirectSnippet which are understood by the default search results UI
- custom ones (possibly reusing SearchResult::$extensionData)
- A priority may also be provided to handle conflicting targets: words in the query may want highlight the redirectsSnippet but if subpageof is used and it matches a redirect it's perhaps preferable to highlight the redirect that subpageof matched.
- A transformation mechanism, the builder should accept a method to transform the result returned from elastic into the target string.