摘要
我正在使用Elastic search 5.2来查询文档的多个字段,并突出显示响应。但是我希望突出显示在结果片段的中心 - 它会持续地出现在片段的末尾而不是
text text text <em>highlighted</em> text text text
text text text text text <em>highlighted</em>
我尝试使用普通,贴子和快速矢量荧光笔(见下文),但没有运气移动每个片段中的<em>
标签。使用矢量荧光笔似乎有一些效果,但是即使我对边界检测器进行了更改,片段也会回来太长时间
示例索引
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "my_tokenizer",
"filter": [ "lowercase" ],
},
},
"tokenizer": {
"my_tokenizer": {
"type": "edge_ngram",
"min_gram": 3,
"max_gram": 25,
"token_chars": [ "letter", "digit" ],
},
},
},
},
"mappings": {
"doc": {
"properties": {
"page_text": {
"type": "text",
// "term_vector": "with_positions_offsets", // enable this for FVH
"analyzer": "my_analyzer",
},
},
},
},
}
示例查询
{
"query": {
"match_phrase_prefix" : {
"page_text" : {
"query" : "position",
},
},
},
}
示例输出片段:ming it. Then so does over sent dull on. Likewise offended humoured mrs fat trifling answered. On ye <em>position</em>
理想情况下,示例输出在结束</em>
第二个示例片段,搜索词“posit”:ming it. Then so does over sent dull on. Likewise offended humoured mrs fat trifling answered. On ye <em>posit</em>
字符串“posit”再次作为单词“position”的一部分返回,但这次单词被切成两半
如何最好地纠正这个问题?