# Ngram analyzer configure with startswith logic

**URL:** <https://discuss.elastic.co/t/ngram-analyzer-configure-with-startswith-logic/236699>\
**Category:** Elasticsearch\
**Created:** [June 11, 2020, 12:23pm UTC](https://discuss.elastic.co/t/ngram-analyzer-configure-with-startswith-logic/236699 "2020-06-11T12:23:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![buka\_bidzina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/buka_bidzina/32/50141_2.png) [@buka\_bidzina](https://discuss.elastic.co/u/buka_bidzina)\
**Post date:** [June 11, 2020, 12:23pm UTC](https://discuss.elastic.co/t/ngram-analyzer-configure-with-startswith-logic/236699/1 "2020-06-11T12:23:26Z")

</div>

Hello everyone..  
Currently i am using ngram analyzer which is analyzing text like that way:  
forinstance: Apple iPhone -\> app, appl, apple, ppl, pple,ple,iph,ipho,hone and so on.

But I want it to create tokens like this:  
Apple Iphone-\> app, appl apple, iph, ipho,iphon,iphone

> Index Settings

```
PUT index
    {
      "settings": {
        "index": {
          "max_ngram_diff": 50
        },
        "analysis": {
          "filter": {
            "custom_shingle": {
              "max_shingle_size": "2",
              "min_shingle_size": "2",
              "output_unigrams": true,
              "type": "shingle"
            },
            "my_char_filter": {
              "pattern": " ",
              "type": "pattern_replace",
              "replacement": ""
            }
          },
          "analyzer": {
            "nGram_analyzer": {
              "filter": [
                "lowercase"
              ],
              "tokenizer": "nGram_tokenizer"
            },
            "bigram_analyzer": {
              "filter": [
                "lowercase",
                "custom_shingle",
                "my_char_filter"
              ],
              "tokenizer": "standard"
            }
          },
          "tokenizer": {
          "nGram_tokenizer": {
            "type": "ngram",
            "min_gram": 3,
            "max_gram": 20,
            "token_chars": [
              "letter",
              "digit"
            ]
          }
        }
        }
      }
    }

```

---

<div class="post-metadata">

**Author:** ![buka\_bidzina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/buka_bidzina/32/50141_2.png) [@buka\_bidzina](https://discuss.elastic.co/u/buka_bidzina)\
**Post date:** [June 11, 2020, 1:13pm UTC](https://discuss.elastic.co/t/ngram-analyzer-configure-with-startswith-logic/236699/2 "2020-06-11T13:13:04Z")

</div>

```
"nGram_tokenizer": {
            "type": "edge_ngram",
            "min_gram": 3,
            "max_gram": 20,
            "token_chars": [
              "letter",
              "digit"
            ]
          }
```

---

<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 9, 2020, 1:13pm UTC](https://discuss.elastic.co/t/ngram-analyzer-configure-with-startswith-logic/236699/3 "2020-07-09T13:13:09Z")

</div>

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