Skip to content

Plain Highlighter “order”:”none” is not working #58236

@mayanknc

Description

@mayanknc

Elasticsearch version:{
"number" : "7.6.0",
"build_flavor" : "default",
"build_type" : "zip",
"build_hash" : "7f634e9f44834fbc12724506cc1da681b0c3b1e3",
"build_date" : "2020-02-06T00:09:00.449973Z",
"build_snapshot" : false,
"lucene_version" : "8.4.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},

Plugins installed: []

JVM version :1.8

OS version :Windows 10

Description of the problem including expected versus actual behavior:

Hi,

I have created below test_plain_highlighter index. I want highlighted fragments should appear in order as they appear in the field using Plain Highlighter.

I have tried below option,

  • Set "order":"none" in highlight query (as shown in below query).
  • No order is defined in highlight query.
  • Set "order":"score" in highlight query.

But, It always gives highlighted fragments SORTED based on SCORE. I want it in order as they appear in the field. Please help me out.

order

Sorts highlighted fragments by score when set to score . By default, fragments will be output in the order they appear in the field (order: none ). Setting this option to score will output the most relevant fragments first. Each highlighter applies its own logic to compute relevancy scores. See the document How highlighters work internally for more details how different highlighters find the best fragments.

Steps to reproduce:

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."
}

REQUEST

POST /test_plain_highlighter/_search
{
  "highlight": {
    "order": "none",
    "type": "plain",
    "fields": {
      "*": {}
    },
    "fragment_size": 50
  },
  "query": {
    "match": {
      "description": "search string"
    }
  },
  "_source": ""
}

RESPONSE

{
  "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"
          ]
        }
      }
    ]
  }
}

RECEIVED Highlighted Fragment:

[
", 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"
]

EXPECTED Highlighted Fragment:

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions