# Dictionary decompounder: only longest match doesn't work

**URL:** https://discuss.elastic.co/t/dictionary-decompounder-only-longest-match-doesnt-work/303598
**Category:** Elasticsearch
**Created:** [April 29, 2022, 11:49am UTC](https://discuss.elastic.co/t/dictionary-decompounder-only-longest-match-doesnt-work/303598 "2022-04-29T11:49:56Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Arisara\_Pornwattanav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arisara_pornwattanav/32/105036_2.png) [@Arisara\_Pornwattanav](https://discuss.elastic.co/u/Arisara_Pornwattanav)
#### Post date: [April 29, 2022, 11:49am UTC](https://discuss.elastic.co/t/dictionary-decompounder-only-longest-match-doesnt-work/303598/1 "2022-04-29T11:49:56Z")

</div>

Hi I have problem with analyzer: dictionary decompounder. I need the analyzer output as the longest word that match the dictionary.  
So, I set the word\_list: theredapple, redapple, apple  
and I also set **only\_longest\_match: true** as follows:

```auto
{

    "settings": {

        "analysis": {

      "analyzer": {

        "standard_dictionary_decompound": {

          "tokenizer": "whitespace",

          "filter": ["22_char_dictionary_decompound", "lowercase"]

        }

      },

      "filter": {

        "22_char_dictionary_decompound": {

          "type": "dictionary_decompounder",

          "word_list": ["theredpple","redapple", "apple"],

          "max_subword_size": 50,

          "only_longest_match":true

        }

      }

    }

    }

}

```

Then I test the custom analyzer on URL/\_analyze  
with

```auto
{

    "text":"theredapple",

    "analyzer":"standard_dictionary_decompound"

}

```

The result was:

```auto
{

    "tokens": [

        {

            "token": "theredapple",

            "start_offset": 0,

            "end_offset": 11,

            "type": "word",

            "position": 0

        },

        {

            "token": "redapple",

            "start_offset": 0,

            "end_offset": 11,

            "type": "word",

            "position": 0

        },

        {

            "token": "apple",

            "start_offset": 0,

            "end_offset": 11,

            "type": "word",

            "position": 0

        }

    ]

}

```

Which **is not what I expect**. I think if I set **only\_longest\_match:true** , the result might be **only theredapple** , not redapple and apple

Any suggestion about set **only\_longest\_match:true ?.** Or I misunderstand something?

Thank for your help.

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [May 5, 2022, 1:55pm UTC](https://discuss.elastic.co/t/dictionary-decompounder-only-longest-match-doesnt-work/303598/2 "2022-05-05T13:55:52Z")

</div>

That's a good question. I asked around and learned that this means only use the longest match for a given start point. `theredapple` and `redapple` start at different positions so are assumed different tokens, where as `redapple` and `redpear` would only return the longest tokens.

Hope that helps.

---

<div class="post-metadata">

### Author: ![Arisara\_Pornwattanav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/arisara_pornwattanav/32/105036_2.png) [@Arisara\_Pornwattanav](https://discuss.elastic.co/u/Arisara_Pornwattanav)
#### Post date: [May 6, 2022, 5:29am UTC](https://discuss.elastic.co/t/dictionary-decompounder-only-longest-match-doesnt-work/303598/3 "2022-05-06T05:29:34Z")

</div>

Ohhh I got it Thank youu

---

<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: [June 3, 2022, 5:29am UTC](https://discuss.elastic.co/t/dictionary-decompounder-only-longest-match-doesnt-work/303598/4 "2022-06-03T05:29:56Z")

</div>

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