普通荧光笔“order”:“none”在 Elasticsearch 中不起作用

Posted

技术标签:

【中文标题】普通荧光笔“order”:“none”在 Elasticsearch 中不起作用【英文标题】:Plain Highlighter "order":"none" is not working in Elasticsearch 【发布时间】:2020-09-25 13:39:16 【问题描述】:

我在 test_plain_highlighter 下创建了索引。我希望突出显示的片段应该按照在字段中出现的顺序出现,使用Plain荧光笔。

我尝试了以下选项,

在高亮查询中设置"order":"none"(如下查询所示)。 无顺序在高亮查询中定义。 在高亮查询中设置"order":"score"

但是,它总是给出突出显示的片段基于分数排序。我希望它按出现在字段中的顺序。请帮帮我。

订购

设置为 score 时,按分数对突出显示的片段进行排序。默认情况下,片段将按照它们在字段中出现的顺序输出(顺序:none)。将此选项设置为 score 将首先输出最相关的片段。每个荧光笔都应用自己的逻辑来计算相关性分数。有关不同荧光笔如何找到最佳片段的更多详细信息,请参阅文档How highlighters work internally。

PUT test_plain_highlighter 


POST /test_plain_highlighter/_doc/1

  "description" : "Lorem Ipsum string Generator that helps to create dummy text for all layout needs. In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to Apple's Pages and Keynote software employs such jumbled text as sample screenplay layout. search facial Lorem ipsum is also featured on Joomla. Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it search string over 2000 years old."

请求

POST /test_plain_highlighter/_search

  "highlight": 
    "order": "none",
    "type": "plain",
    "fields": 
      "*": 
    ,
    "fragment_size": 50
  ,
  "query": 
    "match": 
      "description": "search string"
    
  ,
  "_source": ""

回复


  "took" : 1,
  "timed_out" : false,
  "_shards" : 
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  ,
  "hits" : 
    "total" : 
      "value" : 1,
      "relation" : "eq"
    ,
    "max_score" : 0.79659015,
    "hits" : [
      
        "_index" : "test_plain_highlighter",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 0.79659015,
        "_source" :  ,
        "highlight" : 
          "description" : [
            ", making it <em>search</em> <em>string</em> over 2000 years old.",
            "Lorem Ipsum <em>string</em> Generator that helps to create",
            " layout. <em>search</em> facial Lorem ipsum is also"
          ]
        
      
    ]
  

收到突出显示的片段:

[
", making it `<em>search</em>` `<em>string</em>` over 2000 years old.",
"Lorem Ipsum `<em>string</em>` Generator that helps to create",
" layout. `<em>search</em>` facial Lorem ipsum is also"
]

预期的高亮片段:

[
"Lorem Ipsum `<em>string</em>` Generator that helps to create",
" layout. `<em>search</em>` facial Lorem ipsum is also",
", making it `<em>search</em>` `<em>string</em>` over 2000 years old."
]

【问题讨论】:

【参考方案1】:

他们的团队成员确认 Elasticsearch 代码库中存在错误。

https://github.com/elastic/elasticsearch/issues/58236

【讨论】:

以上是关于普通荧光笔“order”:“none”在 Elasticsearch 中不起作用的主要内容,如果未能解决你的问题,请参考以下文章

色温与光通量有啥关系?为啥荧光灯色温越高光通量越低,成反比?LED色温越高光通量越高,成正比?

箱线图

Django-models进阶

如何在文本上“绘制”荧光笔? [复制]

如何在颤振中创建荧光笔选项?

leetcode1008