高亮显示查询匹配项
高亮显示功能可以突出显示结果中的搜索词,以便您强调查询匹配项。
要高亮显示搜索词,请在查询块外部添加一个 highlight 参数:
GET shakespeare/_search
{
"query": {
"match": {
"text_entry": "life"
}
},
"size": 3,
"highlight": {
"fields": {
"text_entry": {}
}
}
}
结果中的每个文档都包含一个 highlight 对象,其中显示被 <em> 标签包裹的搜索词:
{
"took" : 3,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 805,
"relation" : "eq"
},
"max_score" : 7.450247,
"hits" : [
{
"_index" : "shakespeare",
"_id" : "33765",
"_score" : 7.450247,
"_source" : {
"type" : "line",
"line_id" : 33766,
"play_name" : "Hamlet",
"speech_number" : 60,
"line_number" : "2.2.233",
"speaker" : "HAMLET",
"text_entry" : "my life, except my life."
},
"highlight" : {
"text_entry" : [
"my <em>life</em>, except my <em>life</em>."
]
}
},
{
"_index" : "shakespeare",
"_id" : "51877",
"_score" : 6.873042,
"_source" : {
"type" : "line",
"line_id" : 51878,
"play_name" : "King Lear",
"speech_number" : 18,
"line_number" : "4.6.52",
"speaker" : "EDGAR",
"text_entry" : "The treasury of life, when life itself"
},
"highlight" : {
"text_entry" : [
"The treasury of <em>life</em>, when <em>life</em> itself"
]
}
},
{
"_index" : "shakespeare",
"_id" : "39245",
"_score" : 6.6167283,
"_source" : {
"type" : "line",
"line_id" : 39246,
"play_name" : "Henry V",
"speech_number" : 7,
"line_number" : "4.7.31",
"speaker" : "FLUELLEN",
"text_entry" : "mark Alexanders life well, Harry of Monmouths life"
},
"highlight" : {
"text_entry" : [
"mark Alexanders <em>life</em> well, Harry of Monmouths <em>life</em>"
]
}
}
]
}
}
高亮功能作用于实际的字段内容。UDB-SX 从存储的字段(映射设置为 true 的字段)或从 _source 字段(如果字段未存储)检索这些内容。您可以通过将 force_source 参数设置为 true,强制从 _source 字段检索字段内容。highlight 参数会高亮显示原始词条,即使搜索本身使用了同义词或词干提取。
获取偏移量的方法
为了高亮显示搜索词,高亮器需要每个词条的起始和结束字符偏移量。偏移量标记了词条在原始文本中的位置。高亮器可以从以下来源获取偏移量:
倒排表:当文档被索引时,UDB-SX 会创建一个倒排搜索索引——这是用于搜索文档的核心数据结构。倒排表代表倒排搜索索引,存储每个分析后的词条到出现该词条的文档列表的映射。如果在映射文本字段时将
index_options参数设置为offsets,UDB-SX 会将每个词条的起始和结束字符偏移量添加到倒排索引中。在高亮显示期间,高亮器直接在倒排表上重新运行原始查询以定位每个词条。因此,存储偏移量使得高亮显示对于大字段更高效,因为它不需要重新分析文本。存储词条偏移量需要额外的磁盘空间,但比存储词向量占用的磁盘空间少。词向量:如果在映射文本字段时将
term_vector参数设置为with_positions_offsets,高亮器将使用term_vector来高亮显示字段。存储词向量需要最多的磁盘空间。然而,对于大于 1 MB 的字段以及像前缀或通配符这样的多词条查询,它使高亮显示更快,因为词向量提供了对每个文档词条字典的访问。文本重新分析:在既没有倒排表也没有词向量的情况下,高亮器会重新分析文本来进行高亮显示。对于每个需要高亮显示的文档和每个字段,高亮器创建一个小的内存索引,并通过 Lucene 的查询执行计划器重新运行原始查询,以获取当前文档的低级匹配信息。在大多数用例中,重新分析文本效果良好。然而,对于大字段,这种方法会消耗更多内存和时间。
高亮器类型
UDB-SX 支持三种高亮器实现:plain、unified 和 fvh(快速向量高亮器)。
下表列出了每种高亮器获取偏移量的方法。
| 高亮器 | 获取偏移量的方法 |
|---|---|
unified |
如果 term_vector 设置为 with_positions_offsets,则使用词向量,如果 index_options 设置为 offsets,则使用倒排表, 否则使用文本重新分析。 |
fvh |
词向量。 |
plain |
文本重新分析。 |
设置高亮器类型
要设置高亮器类型,请在 type 字段中指定:
GET shakespeare/_search
{
"query": {
"match": {
"text_entry": "life"
}
},
"highlight": {
"fields": {
"text_entry": { "type": "plain"}
}
}
}
unified 高亮器
unified 高亮器基于 Lucene Unified Highlighter,是 UDB-SX 的默认高亮器。它将文本分割成句子,并将这些句子视为单独的文档,使用 BM25 算法根据相似性对它们进行评分。unified 高亮器支持精确短语和多词条高亮显示,包括模糊、前缀和正则表达式。如果您使用复杂查询来高亮显示多个文档中的多个字段,我们建议在 postings 或 term_vector 字段上使用 unified 高亮器。
fvh 高亮器
fvh 高亮器基于 Lucene Fast Vector Highlighter。要使用此高亮器,您需要存储带有位置偏移量的词向量,这会增加索引大小。fvh 高亮器可以将多个字段中的匹配词条合并到一个结果中。它还可以根据匹配位置为匹配分配权重;因此,当高亮显示一个将短语匹配提升到词条匹配之上的查询时,您可以将短语匹配排序在词条匹配之上。此外,您可以配置 fvh 高亮器以选择返回文本片段的边界,并且可以用不同的标签高亮显示多个单词。
plain 高亮器
plain 高亮器基于标准的 Lucene 高亮器。它要求高亮显示的字段要么单独存储,要么存储在 _source 字段中。plain 高亮器镜像查询匹配逻辑,特别是词条重要性和短语查询中的位置。它适用于大多数用例,但对于大字段可能较慢,因为它必须重新分析要高亮显示的文本。
高亮显示选项
下表描述了您可以在全局或字段级别指定的高亮显示选项。字段级别设置会覆盖全局设置。
| 选项 | 描述 |
|---|---|
| type | 指定要使用的高亮器。有效值为 unified、fvh 和 plain。默认为 unified。 |
| fields | 指定要搜索要高亮显示的文本的字段。支持通配符表达式。如果使用通配符,则只高亮显示 text 和 keyword 字段。例如,您可以将 fields 设置为 my_field* 以包含所有以 my_field 为前缀的 text 和 keyword 字段。 |
| force_source | 指定用于高亮显示的字段值应从 _source 字段获取,而不是从存储的字段值获取。默认为 false。 |
| require_field_match | 指定是否只高亮显示包含搜索查询匹配的字段。默认为 true。要高亮显示所有字段,请将此选项设置为 false。 |
| pre_tags | 以字符串数组的形式指定高亮显示文本的 HTML 起始标签。 |
| post_tags | 以字符串数组的形式指定高亮显示文本的 HTML 结束标签。 |
| tags_schema | 如果将此选项设置为 styled,UDB-SX 会使用内置的标签模式。在此模式中,pre_tags 是 <em class="hlt1">、<em class="hlt2">、<em class="hlt3">、<em class="hlt4">、<em class="hlt5">、<em class="hlt6">、<em class="hlt7">、<em class="hlt8">、<em class="hlt9"> 和 <em class="hlt10">,post_tags 是 </em>。 |
| boundary_chars | 所有边界字符组合成的字符串。 默认为 ".,!? \t\n"。 |
| boundary_scanner | 仅对 unified 和 fvh 高亮器有效。指定是否将高亮显示的片段分割为句子、单词或字符。有效值如下:- sentence:在句子边界处分隔高亮显示的片段,由 BreakIterator 定义。您可以在 boundary_scanner_locale 选项中指定 BreakIterator 的区域设置。- word:在单词边界处分隔高亮显示的片段,由 BreakIterator 定义。您可以在 boundary_scanner_locale 选项中指定 BreakIterator 的区域设置。- chars:在 boundary_chars 中列出的任何字符处分隔高亮显示的片段。仅对 fvh 高亮器有效。 |
| boundary_scanner_locale | 为 boundary_scanner 提供区域设置。有效值是语言标签(例如,"en-US")。默认为 Locale.ROOT。 |
| boundary_max_scan | 当 fvh 高亮器的 boundary_scanner 参数设置为 chars 时,控制扫描边界字符的距离。默认为 20。 |
| encoder | 指定高亮显示的片段在返回前是否应进行 HTML 编码。有效值为 default(不编码)或 html(首先转义 HTML 文本,然后插入高亮显示标签)。例如,如果字段文本是 <h3>Hamlet</h3> 且 encoder 设置为 html,则高亮显示的文本为 "<h3><em>Hamlet</em></h3>"。 |
| fragmenter | 指定如何将文本分割成高亮显示的片段。仅对 plain 高亮器有效。有效值如下:- span(默认):将文本分割成相同大小的片段,但尽量不在高亮显示的词条之间分割文本。- simple:将文本分割成相同大小的片段。 |
| fragment_offset | 指定希望开始高亮显示的字符偏移量。仅对 fvh 高亮器有效。 |
| fragment_size | 高亮显示片段的大小,以字符数指定。如果 number_of_fragments 设置为 0,则忽略 fragment_size。默认为 100。 |
| number_of_fragments | 返回片段的最大数量。如果 number_of_fragments 设置为 0,UDB-SX 将返回整个字段的高亮显示内容。默认为 5。 |
| order | 高亮显示片段的排序顺序。将 order 设置为 score 以按相关性对片段排序。每个高亮器有不同的计算相关性分数的算法。默认为 none。 |
| highlight_query | 指定应高亮显示搜索查询以外的其他查询的匹配项。当您使用更快的查询获取文档匹配,并使用较慢的查询(例如,rescore_query)来优化结果时,highlight_query 选项很有用。我们建议将搜索查询作为 highlight_query 的一部分包含在内。 |
| matched_fields | 合并来自不同字段的匹配项以高亮显示一个字段。此功能最常见的用例是高亮显示以不同方式分析并保存在多字段中的文本。matched_fields 列表中的所有字段必须将 term_vector 字段设置为 with_positions_offsets。合并匹配项的字段是唯一加载的字段,因此将其 store 选项设置为 yes 是有益的。仅对 fvh 高亮器有效。 |
| no_match_size | 如果没有要突出显示的匹配片段,则指定从字段开头返回的字符数。默认为 0。 |
| phrase_limit | 文档中考虑的匹配短语数量。限制 fvh 高亮器分析的短语数量,以避免消耗大量内存。如果使用了 matched_fields,phrase_limit 指定每个匹配字段的短语数量。更高的 phrase_limit 会导致查询时间增加和内存消耗增加。仅对 fvh 高亮器有效。默认为 256。 |
| max_analyzer_offset | 指定高亮请求要分析的字符的最大数量。剩余的文本将不会被处理。如果要高亮显示的文本超过此偏移量,则返回空的高亮显示。高亮请求要分析的字符的最大数量由 index.highlight.max_analyzed_offset 定义。当达到此限制时,会返回错误。将 max_analyzer_offset 设置为低于 index.highlight.max_analyzed_offset 的值以避免错误。 |
统一高亮器的句子扫描器会将大于 fragment_size 的句子在达到 fragment_size 后的第一个单词边界处分割。要返回完整的句子而不分割它们,请将 fragment_size 设置为 0。
更改高亮显示标签
设计您的应用程序代码以解析 highlight 对象的结果并对搜索词执行操作,例如更改颜色、加粗、斜体等。
要更改默认的 em 标签,请在 pretag 和 posttag 参数中指定新标签:
GET shakespeare/_search
{
"query": {
"match": {
"play_name": "Henry IV"
}
},
"size": 3,
"highlight": {
"pre_tags": [
"<strong>"
],
"post_tags": [
"</strong>"
],
"fields": {
"play_name": {}
}
}
}
剧名在响应中被新标签高亮显示:
{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 3205,
"relation" : "eq"
},
"max_score" : 3.548232,
"hits" : [
{
"_index" : "shakespeare",
"_id" : "0",
"_score" : 3.548232,
"_source" : {
"type" : "act",
"line_id" : 1,
"play_name" : "Henry IV",
"speech_number" : "",
"line_number" : "",
"speaker" : "",
"text_entry" : "ACT I"
},
"highlight" : {
"play_name" : [
"<strong>Henry IV</strong>"
]
}
},
{
"_index" : "shakespeare",
"_id" : "1",
"_score" : 3.548232,
"_source" : {
"type" : "scene",
"line_id" : 2,
"play_name" : "Henry IV",
"speech_number" : "",
"line_number" : "",
"speaker" : "",
"text_entry" : "SCENE I. London. The palace."
},
"highlight" : {
"play_name" : [
"<strong>Henry IV</strong>"
]
}
},
{
"_index" : "shakespeare",
"_id" : "2",
"_score" : 3.548232,
"_source" : {
"type" : "line",
"line_id" : 3,
"play_name" : "Henry IV",
"speech_number" : "",
"line_number" : "",
"speaker" : "",
"text_entry" : "Enter KING HENRY, LORD JOHN OF LANCASTER, the EARL of WESTMORELAND, SIR WALTER BLUNT, and others"
},
"highlight" : {
"play_name" : [
"<strong>Henry IV</strong>"
]
}
}
]
}
}
指定高亮查询
默认情况下,UDB-SX 只考虑搜索查询进行高亮显示。如果您使用快速查询获取文档匹配,并使用像 rescore_query 这样较慢的查询来优化结果,那么高亮显示优化后的结果会很有用。您可以通过添加 highlight_query 来实现:
GET shakespeare/_search
{
"query": {
"match": {
"text_entry": {
"query": "thats my name"
}
}
},
"rescore": {
"window_size": 20,
"query": {
"rescore_query": {
"match_phrase": {
"text_entry": {
"query": "thats my name",
"slop": 1
}
}
},
"rescore_query_weight": 5
}
},
"_source": false,
"highlight": {
"order": "score",
"fields": {
"text_entry": {
"highlight_query": {
"bool": {
"must": {
"match": {
"text_entry": {
"query": "thats my name"
}
}
},
"should": {
"match_phrase": {
"text_entry": {
"query": "that is my name",
"slop": 1,
"boost": 10.0
}
}
},
"minimum_should_match": 0
}
}
}
}
}
}
合并来自不同字段的匹配项以高亮显示一个字段
您可以使用 fvh 高亮器合并来自不同字段的匹配项以高亮显示一个字段。此功能最常见的用例是高亮显示以不同方式分析并保存在多字段中的文本。matched_fields 列表中的所有字段必须将 term_vector 字段设置为 with_positions_offsets。合并匹配项的字段是唯一加载的字段,因此将其 store 选项设置为 yes 是有益的。
示例
为 shakespeare 索引创建映射,其中 text_entry 字段使用 standard 分析器进行分析,并有一个使用 english 分析器进行分析的 english 子字段:
PUT shakespeare
{
"mappings" : {
"properties" : {
"text_entry" : {
"type" : "text",
"term_vector": "with_positions_offsets",
"fields": {
"english": {
"type": "text",
"analyzer": "english",
"term_vector": "with_positions_offsets"
}
}
}
}
}
}
standard 分析器将 text_entry 字段分割成单独的单词。您可以通过使用 analyze API 操作来确认这一点:
GET shakespeare/_analyze
{
"text": "bragging of thine",
"field": "text_entry"
}
响应包含按空格分割的原始字符串:
{
"tokens" : [
{
"token" : "bragging",
"start_offset" : 0,
"end_offset" : 8,
"type" : "<ALPHANUM>",
"position" : 0
},
{
"token" : "of",
"start_offset" : 9,
"end_offset" : 11,
"type" : "<ALPHANUM>",
"position" : 1
},
{
"token" : "thine",
"start_offset" : 12,
"end_offset" : 17,
"type" : "<ALPHANUM>",
"position" : 2
}
]
}
english 分析器不仅将字符串分割成单词,还对词条进行词干提取并移除停用词。您可以通过对 text_entry.english 字段使用 analyze API 操作来确认这一点:
GET shakespeare/_analyze
{
"text": "bragging of thine",
"field": "text_entry.english"
}
响应包含词干提取后的单词:
{
"tokens" : [
{
"token" : "brag",
"start_offset" : 0,
"end_offset" : 8,
"type" : "<ALPHANUM>",
"position" : 0
},
{
"token" : "thine",
"start_offset" : 12,
"end_offset" : 17,
"type" : "<ALPHANUM>",
"position" : 2
}
]
}
要搜索单词 bragging 的所有形式,请使用以下查询:
GET shakespeare/_search
{
"query": {
"query_string": {
"query": "text_entry.english:bragging",
"fields": [
"text_entry"
]
}
},
"highlight": {
"order": "score",
"fields": {
"text_entry": {
"matched_fields": [
"text_entry",
"text_entry.english"
],
"type": "fvh"
}
}
}
}
响应在 text_entry 字段中高亮显示了单词 “bragging” 的所有版本:
{
"took" : 5,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 26,
"relation" : "eq"
},
"max_score" : 10.153671,
"hits" : [
{
"_index" : "shakespeare",
"_id" : "56666",
"_score" : 10.153671,
"_source" : {
"type" : "line",
"line_id" : 56667,
"play_name" : "macbeth",
"speech_number" : 60,
"line_number" : "2.3.118",
"speaker" : "MACBETH",
"text_entry" : "Is left this vault to brag of."
},
"highlight" : {
"text_entry" : [
"Is left this vault to <em>brag</em> of."
]
}
},
{
"_index" : "shakespeare",
"_id" : "71445",
"_score" : 9.284528,
"_source" : {
"type" : "line",
"line_id" : 71446,
"play_name" : "Much Ado about nothing",
"speech_number" : 18,
"line_number" : "5.1.65",
"speaker" : "LEONATO",
"text_entry" : "As under privilege of age to brag"
},
"highlight" : {
"text_entry" : [
"As under privilege of age to <em>brag</em>"
]
}
},
{
"_index" : "shakespeare",
"_id" : "86782",
"_score" : 9.284528,
"_source" : {
"type" : "line",
"line_id" : 86783,
"play_name" : "Romeo and Juliet",
"speech_number" : 8,
"line_number" : "2.6.31",
"speaker" : "JULIET",
"text_entry" : "Brags of his substance, not of ornament:"
},
"highlight" : {
"text_entry" : [
"<em>Brags</em> of his substance, not of ornament:"
]
}
},
{
"_index" : "shakespeare",
"_id" : "44531",
"_score" : 8.552448,
"_source" : {
"type" : "line",
"line_id" : 44532,
"play_name" : "King John",
"speech_number" : 15,
"line_number" : "3.1.124",
"speaker" : "CONSTANCE",
"text_entry" : "A ramping fool, to brag and stamp and swear"
},
"highlight" : {
"text_entry" : [
"A ramping fool, to <em>brag</em> and stamp and swear"
]
}
},
{
"_index" : "shakespeare",
"_id" : "63208",
"_score" : 8.552448,
"_source" : {
"type" : "line",
"line_id" : 63209,
"play_name" : "Merchant of Venice",
"speech_number" : 11,
"line_number" : "3.4.79",
"speaker" : "PORTIA",
"text_entry" : "A thousand raw tricks of these bragging Jacks,"
},
"highlight" : {
"text_entry" : [
"A thousand raw tricks of these <em>bragging</em> Jacks,"
]
}
},
{
"_index" : "shakespeare",
"_id" : "73026",
"_score" : 8.552448,
"_source" : {
"type" : "line",
"line_id" : 73027,
"play_name" : "Othello",
"speech_number" : 75,
"line_number" : "2.1.242",
"speaker" : "IAGO",
"text_entry" : "but for bragging and telling her fantastical lies:"
},
"highlight" : {
"text_entry" : [
"but for <em>bragging</em> and telling her fantastical lies:"
]
}
},
{
"_index" : "shakespeare",
"_id" : "85974",
"_score" : 8.552448,
"_source" : {
"type" : "line",
"line_id" : 85975,
"play_name" : "Romeo and Juliet",
"speech_number" : 20,
"line_number" : "1.5.70",
"speaker" : "CAPULET",
"text_entry" : "And, to say truth, Verona brags of him"
},
"highlight" : {
"text_entry" : [
"And, to say truth, Verona <em>brags</em> of him"
]
}
},
{
"_index" : "shakespeare",
"_id" : "96800",
"_score" : 8.552448,
"_source" : {
"type" : "line",
"line_id" : 96801,
"play_name" : "Titus Andronicus",
"speech_number" : 60,
"line_number" : "1.1.311",
"speaker" : "SATURNINUS",
"text_entry" : "Agree these deeds with that proud brag of thine,"
},
"highlight" : {
"text_entry" : [
"Agree these deeds with that proud <em>brag</em> of thine,"
]
}
},
{
"_index" : "shakespeare",
"_id" : "18189",
"_score" : 7.9273787,
"_source" : {
"type" : "line",
"line_id" : 18190,
"play_name" : "As you like it",
"speech_number" : 12,
"line_number" : "5.2.30",
"speaker" : "ROSALIND",
"text_entry" : "and Caesars thrasonical brag of I came, saw, and"
},
"highlight" : {
"text_entry" : [
"and Caesars thrasonical <em>brag</em> of I came, saw, and"
]
}
},
{
"_index" : "shakespeare",
"_id" : "32054",
"_score" : 7.9273787,
"_source" : {
"type" : "line",
"line_id" : 32055,
"play_name" : "Cymbeline",
"speech_number" : 52,
"line_number" : "5.5.211",
"speaker" : "IACHIMO",
"text_entry" : "And then a mind put int, either our brags"
},
"highlight" : {
"text_entry" : [
"And then a mind put int, either our <em>brags</em>"
]
}
}
]
}
}
要为单词 “bragging” 的原始形式分配更高的分数,您可以提升 text_entry 字段:
GET shakespeare/_search
{
"query": {
"query_string": {
"query": "bragging",
"fields": [
"text_entry^5",
"text_entry.english"
]
}
},
"highlight": {
"order": "score",
"fields": {
"text_entry": {
"matched_fields": [
"text_entry",
"text_entry.english"
],
"type": "fvh"
}
}
}
}
响应首先列出包含单词 “bragging” 的文档:
{
"took" : 17,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 26,
"relation" : "eq"
},
"max_score" : 49.746853,
"hits" : [
{
"_index" : "shakespeare",
"_id" : "45739",
"_score" : 49.746853,
"_source" : {
"type" : "line",
"line_id" : 45740,
"play_name" : "King John",
"speech_number" : 10,
"line_number" : "5.1.51",
"speaker" : "BASTARD",
"text_entry" : "Of bragging horror: so shall inferior eyes,"
},
"highlight" : {
"text_entry" : [
"Of <em>bragging</em> horror: so shall inferior eyes,"
]
}
},
{
"_index" : "shakespeare",
"_id" : "63208",
"_score" : 47.077244,
"_source" : {
"type" : "line",
"line_id" : 63209,
"play_name" : "Merchant of Venice",
"speech_number" : 11,
"line_number" : "3.4.79",
"speaker" : "PORTIA",
"text_entry" : "A thousand raw tricks of these bragging Jacks,"
},
"highlight" : {
"text_entry" : [
"A thousand raw tricks of these <em>bragging</em> Jacks,"
]
}
},
{
"_index" : "shakespeare",
"_id" : "68474",
"_score" : 47.077244,
"_source" : {
"type" : "line",
"line_id" : 68475,
"play_name" : "A Midsummer nights dream",
"speech_number" : 101,
"line_number" : "3.2.427",
"speaker" : "PUCK",
"text_entry" : "Thou coward, art thou bragging to the stars,"
},
"highlight" : {
"text_entry" : [
"Thou coward, art thou <em>bragging</em> to the stars,"
]
}
},
{
"_index" : "shakespeare",
"_id" : "73026",
"_score" : 47.077244,
"_source" : {
"type" : "line",
"line_id" : 73027,
"play_name" : "Othello",
"speech_number" : 75,
"line_number" : "2.1.242",
"speaker" : "IAGO",
"text_entry" : "but for bragging and telling her fantastical lies:"
},
"highlight" : {
"text_entry" : [
"but for <em>bragging</em> and telling her fantastical lies:"
]
}
},
{
"_index" : "shakespeare",
"_id" : "39816",
"_score" : 44.679565,
"_source" : {
"type" : "line",
"line_id" : 39817,
"play_name" : "Henry V",
"speech_number" : 28,
"line_number" : "5.2.138",
"speaker" : "KING HENRY V",
"text_entry" : "armour on my back, under the correction of bragging"
},
"highlight" : {
"text_entry" : [
"armour on my back, under the correction of <em>bragging</em>"
]
}
},
{
"_index" : "shakespeare",
"_id" : "63200",
"_score" : 44.679565,
"_source" : {
"type" : "line",
"line_id" : 63201,
"play_name" : "Merchant of Venice",
"speech_number" : 11,
"line_number" : "3.4.71",
"speaker" : "PORTIA",
"text_entry" : "Like a fine bragging youth, and tell quaint lies,"
},
"highlight" : {
"text_entry" : [
"Like a fine <em>bragging</em> youth, and tell quaint lies,"
]
}
},
{
"_index" : "shakespeare",
"_id" : "56666",
"_score" : 10.153671,
"_source" : {
"type" : "line",
"line_id" : 56667,
"play_name" : "macbeth",
"speech_number" : 34,
"line_number" : "2.3.118",
"speaker" : "MACBETH",
"text_entry" : "Is left this vault to brag of."
},
"highlight" : {
"text_entry" : [
"Is left this vault to <em>brag</em> of."
]
}
},
{
"_index" : "shakespeare",
"_id" : "71445",
"_score" : 9.284528,
"_source" : {
"type" : "line",
"line_id" : 71446,
"play_name" : "Much Ado about nothing",
"speech_number" : 18,
"line_number" : "5.1.65",
"speaker" : "LEONATO",
"text_entry" : "As under privilege of age to brag"
},
"highlight" : {
"text_entry" : [
"As under privilege of age to <em>brag</em>"
]
}
},
{
"_index" : "shakespeare",
"_id" : "86782",
"_score" : 9.284528,
"_source" : {
"type" : "line",
"line_id" : 86783,
"play_name" : "Romeo and Juliet",
"speech_number" : 8,
"line_number" : "2.6.31",
"speaker" : "JULIET",
"text_entry" : "Brags of his substance, not of ornament:"
},
"highlight" : {
"text_entry" : [
"<em>Brags</em> of his substance, not of ornament:"
]
}
},
{
"_index" : "shakespeare",
"_id" : "44531",
"_score" : 8.552448,
"_source" : {
"type" : "line",
"line_id" : 44532,
"play_name" : "King John",
"speech_number" : 15,
"line_number" : "3.1.124",
"speaker" : "CONSTANCE",
"text_entry" : "A ramping fool, to brag and stamp and swear"
},
"highlight" : {
"text_entry" : [
"A ramping fool, to <em>brag</em> and stamp and swear"
]
}
}
]
}
}
查询限制
请注意以下限制:
在提取要突出显示的词条时,高亮器不会反映查询的布尔逻辑。因此,对于一些复杂的布尔查询,例如嵌套布尔查询和使用
minimum_should_match的查询,UDB-SX 可能会高亮显示与查询匹配不对应的词条。fvh高亮器不支持跨度查询。