0

我正在使用 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.

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

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

4

1 回答 1

0

请注意,您可以调整突出显示参数,检查上面的配置:

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

这里还有另一个链接可以帮助您了解奇怪的结果:Fragment_size 在弹性搜索突出显示中的奇怪行为

于 2015-08-05T21:10:47.143 回答