How to highlight each search term in a search using a different highlighting attribute.
Remarks
To highlight each term in a search with different highlighting criteria,
- Search using the flags dtsSearchWantHitsByWord, dtsSearchWantHitsArray, and dtsSearchWantHitsByWordOrdinals in SearchJob, so the SearchResults will contain HitsByWord information with the hit offsets of each search term.
- Set the flag dtsConvertMultiHighlight in FileConverter
- Pass the HitsByWord result from the search results item to FileConverter in FileConverter.HitsByWord. If you set up FileConverter using SetInputItem, this will happen automatically.
- Use BeforeHit and AfterHit to pass the highlighting strings as an array, with the first character (which must be punctuation) used as a delimiter.
The words listed in the HitsByWord table will be assigned to the highlight markings listed in BeforeHit and AfterHit. If HitsByWord contains more items than BeforeHit or AfterHit, items in BeforeHit and AfterHit will be reused in order.
Limitations and requirements
Because HitsByWord treats each phrase as a single item, all words in a phrase will have the same color.
Because SearchResults.UrlDecodeItem does not preserve HitsByWord information, it cannot be used to create a SearchResults object to use with multiple highlighting.
Group