弹性/亮点 [英] elasticsearch / lucene highlight

查看:105
本文介绍了弹性/亮点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ElasticSearch索引文件。



我的映射是:

 code>mongodocid:{
boost:1.0,
store:yes,
type:string
},
fulltext:{
boost:1.0,
index:analyze,
store:yes,
type string,
term_vector:with_positions_offsets
}

突出显示完整的全文我将 number_of_framgments 设置为0



如果我执行以下类似Lucene的字符串查询:

  {
highlight:{
pre_tags:< b>,
fields:{
fulltext:{
number_of_fragments:0
}
},
post_tags:< / b> ;
},
query:{
query_string:{
query:fulltext:test
}
},
size:100
}

对于结果集中的一些文档,突出显示的全文小于全文本身。
由于我将 number_of_fragments 设置为0和 pre_tags / post_tags 被添加,这不应该发生。



现在出现了奇怪的行为:如果我只是通过这样做搜索一个失败的元素:

  {
highlight:{
pre_tags:< b>,
字段:{
fulltext:{
number_of_fragments:0
}
},
post_tags:< / b>
},
query:{
query_string:{
query:fulltext:test AND mongodocid:4d0a861c2ebef6032c00b1ec
}
},
size:100
}

然后一切正常。



任何想法?

解决方案

在0.14.0(参见#479 )。截至撰写0.14.0尚未发布,您可以尝试高手吗?


I'm using ElasticSearch to index documents.

My mapping is:

"mongodocid": {
  "boost": 1.0,
  "store": "yes",
  "type": "string"
},
"fulltext": {
  "boost": 1.0,
  "index": "analyzed",
  "store": "yes",
  "type": "string",
  "term_vector": "with_positions_offsets"
}

To highlight the complete fulltext I am setting number_of_framgments to 0.

If I do the following Lucene-like string query:

{
  "highlight": {
    "pre_tags": "<b>",
    "fields": {
      "fulltext": {
        "number_of_fragments": 0
      }
    },
    "post_tags": "</b>"
  },
  "query": {
    "query_string": {
      "query": "fulltext:test"
    }
  },
  "size": 100
}

For some documents in the result set the length of the highlighted fulltext is smaller than the fulltext itself. Since I am setting number_of_fragments to 0 and pre_tags/post_tags are added this should not happen.

Now comes the strange behaviour: If I only search for one of the failing elements by doing this:

{
  "highlight": {
    "pre_tags": "<b>",
    "fields": {
      "fulltext": {
        "number_of_fragments": 0
      }
    },
    "post_tags": "</b>"
  },
  "query": {
    "query_string": {
      "query": "fulltext:test AND mongodocid:4d0a861c2ebef6032c00b1ec"
    }
  },
  "size": 100
}

then all works fine.

Any ideas?

解决方案

Sounds like issue which has been fixed in 0.14.0 (see #479). As of writing the 0.14.0 hasn't been released yet, can you try master?

这篇关于弹性/亮点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆