| 392 | // many highlights in the search result UI, we can come back here |
| 393 | // and change it to something more appropriate. |
| 394 | function getHighlightConfiguration(query, highlights) { |
| 395 | const fields = {} |
| 396 | if (highlights.includes('title')) { |
| 397 | fields.title = { |
| 398 | fragment_size: 200, |
| 399 | number_of_fragments: 1, |
| 400 | } |
| 401 | } |
| 402 | if (highlights.includes('headings')) { |
| 403 | fields.headings = { fragment_size: 150, number_of_fragments: 2 } |
| 404 | } |
| 405 | if (highlights.includes('content')) { |
| 406 | // The 'no_match_size' is so we can display *something* for the |
| 407 | // preview if there was no highlight match at all within the content. |
| 408 | fields.content = { |
| 409 | fragment_size: 150, |
| 410 | number_of_fragments: 1, |
| 411 | no_match_size: 150, |
| 412 | |
| 413 | highlight_query: { |
| 414 | match_phrase_prefix: { |
| 415 | content: { |
| 416 | query, |
| 417 | }, |
| 418 | }, |
| 419 | }, |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | return { |
| 424 | pre_tags: ['<mark>'], |
| 425 | post_tags: ['</mark>'], |
| 426 | fields, |
| 427 | } |
| 428 | } |