generated from amazon-archives/__template_Custom
-
Notifications
You must be signed in to change notification settings - Fork 181
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Related design for relevance-based search in SQL/PPL engine - #182
TODO List
- Support the
highlightfunction by including it in the search engine - Enable
highlightfunction in SQL syntax and parser, including parameters - Enable
highlightfunction in PPL syntax and parser, including parameters - Add unit tests
- Add integration tests for
highlighting - Update the user manual - append to existing
matchsearch documentation
Function Details
(reference: https://opensearch.org/docs/latest/opensearch/ux/#highlight-query-matches)
The highlighting function adds search term results to the service response for matched terms in fields. Highlighting only works in tandem with match-search queries. The list of highlighted fields must be present in a relevance-based search function, or else the highlighted fields will result in a syntax error.
Syntax
highlight([field_list, …][, option=<option_value>]*)
Available Options
- pre_tags: per-term tag to embed in the highlighted result, default is
<em> - post_tags: post-term tag to embed in the highlighted result, default is
</em>
Sample query
GET shakespeare/_search
{
"query": {
"match": {
"text_entry": "life"
}
},
"highlight": {
"fields": {
"text_entry": {}
}
}
}
SQL
SELECT highlight("text_entry") as "highlight_text_entry" FROM shakespeare WHERE match("text_entry", "life");
PPL
source=shakespeare | where match("text_entry", "life") | highlight("text_entry")
Sample response
| highlight_text_entry |
| "my <em>life</em>, except my <em>life</em>." |
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request