Use Elasticsearch fragments for issue description snippets in search results
Problem
Today we truncate search results and highlight the matching text if it appears in the first 200 chars of the issue description. If the highlighted text is truncated out then there will be nothing to highlight.
Solution
Elasticsearch highlighting is designed to exactly handle a situation like our issue descriptions. You can control the fragment sizes and max number of fragments to return. As such we could just use the fragments themselves as the description we display which would allow us to always show the highlight even if it is much later in the description. Additionally it would allow us to show multiple highlights later in the doc.
Prior context
The following discussion from !43124 (merged) should be addressed:
-
@DylanGriffith started a discussion: I wonder if longer term we actually should just make use of the ES fragments instead of truncating it ourselves. The main reason we did not do this for code search is that we are trying to display the code line by line and the fragments did not work with that. In the case of issue description it seems well suited to how ES handles this.
I will extract this as a follow up issue here.