【问题标题】:elasticsearch / lucene highlightelasticsearch / lucene高亮
【发布时间】:2010-12-22 18:58:04
【问题描述】:

我正在使用 ElasticSearch 来索引文档。

我的映射是:

"mongodocid": {
  "boost": 1.0,
  "store": "yes",
  "type": "string"
},
"fulltext": {
  "boost": 1.0,
  "index": "analyzed",
  "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>",
    "fields": {
      "fulltext": {
        "number_of_fragments": 0
      }
    },
    "post_tags": "</b>"
  },
  "query": {
    "query_string": {
      "query": "fulltext:test AND mongodocid:4d0a861c2ebef6032c00b1ec"
    }
  },
  "size": 100
}

然后一切正常。

有什么想法吗?

【问题讨论】:

    标签: lucene elasticsearch


    【解决方案1】:

    听起来像是 0.14.0 中已修复的问题(请参阅 #479)。截至发稿0.14.0还没有发布,可以试试master吗?

    【讨论】:

      猜你喜欢
      • 2012-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多