0

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

我尝试了以下选项,

  • 在高亮查询中设置“order”:“none”(如下查询所示)。
  • 高亮查询中没有定义顺序。
  • 在高亮查询中设置“order”:“score” 。

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

命令

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

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."
]
4

1 回答 1

0

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

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

于 2021-02-23T12:39:30.613 回答