在ElasticSearch中,当将number_of_fragments指定为0以检索字段的所有内容时,我看到它突出显示了与搜索词匹配的所有标记,并且当搜索词可以标记为2个或更多标记时这是错误的。
"must" => [
%{
"query_string" => %{
"default_operator" => "AND",
"fields" => ["message_parse"],
"query" => "success after"
}
},
%{"match_phrase" => %{"message_parse" => %{"query" => "success after"}}}
]
结果:
"highlight" => %{
"message_parse" => ["<em>success</em>_<em>after</em> and <em>success</em> before and <em>after</em> abc <em>success</em> <em>after</em>"]
},
使用突出显示查询和匹配短语查询解决我的情况