# Wrong highlight when using subword preserver original

**URL:** <https://discuss.elastic.co/t/wrong-highlight-when-using-subword-preserver-original/65883>\
**Category:** Elasticsearch\
**Created:** [November 12, 2016, 4:48pm UTC](https://discuss.elastic.co/t/wrong-highlight-when-using-subword-preserver-original/65883 "2016-11-12T16:48:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cristiana\_Tiugan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cristiana_tiugan/32/93274_2.png) [@Cristiana\_Tiugan](https://discuss.elastic.co/u/Cristiana_Tiugan)\
**Post date:** [November 12, 2016, 4:48pm UTC](https://discuss.elastic.co/t/wrong-highlight-when-using-subword-preserver-original/65883/1 "2016-11-12T16:48:13Z")

</div>

Hello!  
I have an analyzer with extended\_whitespace tokenizer and word\_delimiter filter.  
Something like:

```auto
"analysis": {
      "tokenizer": {
        "extended_whitespace": {
          "type": "pattern",
          "pattern": "\\s+"
        }
      },
    "filter": {
          "subword": {
          "type": "word_delimiter",
          "preserve_original": true,
          "catenate_numbers": true
        }
    },
    "analyzer": {
      "search_fulltext_analyzer": {
          "tokenizer": "extended_whitespace",
          "filter": [
            "subword",
            "lowercase",
            "filter_ascii_folding"
          ],
          "char_filter": [
            "url_encode_pattern"
          ]
        },
    }

```

My problem is that if i have a text like: "NODE\_PATH=/usr/lib/node\_modules ./upgrade-indices.js upgrades"  
The highlight will be wrong:

```auto
 "{highlight}NODE_PATH=/usr/lib/node{/highlight}_modules ./upgrade-indices.js upgrades"

```

Instead of

```auto
"{highlight}NODE{/highlight}_PATH=/usr/lib/{highlight}node{/highlight}_modules ./upgrade-indices.js upgrades"

```

I know it has something to do with the offsets. But I can't find a solution.  
This is the analyze api result:

```auto
{
  "tokens": [
    {
      "token": "node_path=/usr/lib/node_modules",
      "start_offset": 0,
      "end_offset": 31,
      "type": "word",
      "position": 0
    },
    {
      "token": "node",
      "start_offset": 0,
      "end_offset": 4,
      "type": "word",
      "position": 0
    },
    {
      "token": "path",
      "start_offset": 5,
      "end_offset": 9,
      "type": "word",
      "position": 1
    },
    {
      "token": "usr",
      "start_offset": 11,
      "end_offset": 14,
      "type": "word",
      "position": 2
    },
    {
      "token": "lib",
      "start_offset": 15,
      "end_offset": 18,
      "type": "word",
      "position": 3
    },
    {
      "token": "node",
      "start_offset": 19,
      "end_offset": 23,
      "type": "word",
      "position": 4
    },
    {
      "token": "modules",
      "start_offset": 24,
      "end_offset": 31,
      "type": "word",
      "position": 5
    },
    {
      "token": "./upgrade-indices.js",
      "start_offset": 32,
      "end_offset": 52,
      "type": "word",
      "position": 6
    },
    {
      "token": "upgrade",
      "start_offset": 34,
      "end_offset": 41,
      "type": "word",
      "position": 6
    },
    {
      "token": "indices",
      "start_offset": 42,
      "end_offset": 49,
      "type": "word",
      "position": 7
    },
    {
      "token": "js",
      "start_offset": 50,
      "end_offset": 52,
      "type": "word",
      "position": 8
    },
    {
      "token": "upgrades",
      "start_offset": 53,
      "end_offset": 61,
      "type": "word",
      "position": 9
    }
  ]
}

```

---

<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:** [December 10, 2016, 4:48pm UTC](https://discuss.elastic.co/t/wrong-highlight-when-using-subword-preserver-original/65883/2 "2016-12-10T16:48:44Z")

</div>

Closed on December 10, 2016, 4:48pm UTC

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