# Plain Highlighter "order":"none" is not working

**URL:** <https://discuss.elastic.co/t/plain-highlighter-order-none-is-not-working/236030>\
**Category:** Elasticsearch\
**Created:** [June 6, 2020, 10:47am UTC](https://discuss.elastic.co/t/plain-highlighter-order-none-is-not-working/236030 "2020-06-06T10:47:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mayanknc](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mayanknc/32/115266_2.png) [@mayanknc](https://discuss.elastic.co/u/mayanknc)\
**Post date:** [June 6, 2020, 10:47am UTC](https://discuss.elastic.co/t/plain-highlighter-order-none-is-not-working/236030/1 "2020-06-06T10:47:52Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-request-highlighting.html#highlighter-internal-work) for more details how different highlighters find the best fragments.

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 4, 2020, 10:47am UTC](https://discuss.elastic.co/t/plain-highlighter-order-none-is-not-working/236030/2 "2020-07-04T10:47:56Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
