【问题标题】:ElasticSearch highlights results repeats snippetsElasticSearch 突出显示结果重复片段
【发布时间】:2015-02-27 15:15:42
【问题描述】:

我正在使用 FOSElasticaBundle 来索引具有此配置的 ES 文档:

index:
analysis:
    analyzer:
        custom_analyzer:
            type:           custom
            tokenizer:      nGram
            filter:         [stopwords, asciifolding ,lowercase, snowball, elision, worddelimiter]
        custom_search_analyzer:
            type:           custom
            tokenizer:      standard
            filter:         [stopwords, asciifolding ,lowercase, snowball, elision, worddelimiter]
    tokenizer:
        nGram:
            type:           nGram
            min_gram:       2
            max_gram:       20
    filter:
        snowball:
            type:           snowball
            language:       French
        elision:
            type:           elision
            articles:       [l, m, t, qu, n, s, j, d]
        stopwords:
            type:           stop
            stopwords:      [_french_]
            ignore_case:    true
        worddelimiter:
            type:           word_delimiter
    types:
        document:
            indexable_callback:         'isIndexable'
            mappings:
                title:
                    boost:              3
                    index_analyzer:     custom_analyzer
                    search_analyzer:    custom_search_analyzer
                summary:
                    boost:              2
                    index_analyzer:     custom_analyzer
                    search_analyzer:    custom_search_analyzer
                description:
                    boost:              1
                    index_analyzer:     custom_analyzer
                    search_analyzer:    custom_search_analyzer

我正在尝试使用 ES 的高亮功能,这里是一个请求示例:

{
  "query":
  {
    "bool":
    {
      "must":
      [
        {
          "query_string": {
            "query": "blonde",
            "default_field": "_all"
          }
        }
      ]
    }
  },
  "highlight": {
    "fields": {
      "*": {  }
    }
  }
}

给出结果:

"highlight": {

    "title": [
        "Une jeune personne b<em>personne blonde se</em><em>ersonne blonde se te</em><em>blonde se tenait e</em>n partie double, elle avait choisi."
    ]

}

原文为Une jeune personne blonde se tenait en partie double, elle avait choisi.

我已经用不同的分析器配置 + 重新索引文档进行了一些测试,但我从来没有得到所有 sn-p 的一个很好的亮点:有时,突出显示一个,而不是其他的,有时,没有,等等。

分析器和突出显示过程之间有什么关系?我的配置有什么问题?

【问题讨论】:

  • 发布该索引的完整映射。
  • 谢谢,这是完整的配置

标签: symfony elasticsearch foselasticabundle


【解决方案1】:

注意你可以调整你的高亮参数,检查上面的配置:

"highlight": {
        "number_of_fragments": 5,
        "type": "plain",
        "fields": {
            "*": {
                "fragment_size": 100
            }
        }
    }

这里有另一个链接可以帮助您了解奇怪的结果:Curious behaviour of fragment_size in elasticsearch highlighting

【讨论】:

    猜你喜欢
    • 2015-09-09
    • 1970-01-01
    • 2013-08-30
    • 2013-05-22
    • 1970-01-01
    • 2015-03-30
    • 1970-01-01
    • 2016-03-13
    • 1970-01-01
    相关资源
    最近更新 更多