# Token Chars Mapping to Ngram Filter ElasticSearch NEST

**URL:** <https://discuss.elastic.co/t/token-chars-mapping-to-ngram-filter-elasticsearch-nest/54131>\
**Category:** Elasticsearch\
**Created:** [June 28, 2016, 8:56am UTC](https://discuss.elastic.co/t/token-chars-mapping-to-ngram-filter-elasticsearch-nest/54131 "2016-06-28T08:56:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ASN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asn/32/10535_2.png) [@ASN](https://discuss.elastic.co/u/ASN)\
**Post date:** [June 28, 2016, 8:56am UTC](https://discuss.elastic.co/t/token-chars-mapping-to-ngram-filter-elasticsearch-nest/54131/1 "2016-06-28T08:56:53Z")

</div>

I'm trying to replicate the below mappings using NEST and facing an issue while mapping the token chars to the tokenizer.

```
{
   "settings": {
      "analysis": {
         "filter": {
            "nGram_filter": {
               "type": "nGram",
               "min_gram": 2,
               "max_gram": 20,
               "token_chars": [
                  "letter",
                  "digit",
                  "punctuation",
                  "symbol"
               ]
            }
         },
         "analyzer": {
            "nGram_analyzer": {
               "type": "custom",
               "tokenizer": "whitespace",
               "filter": [
                  "lowercase",
                  "asciifolding",
                  "nGram_filter"
               ]
            }
         }
      }
   }

```

I was able to replicate everything except the token chars part. Can some one help in doing so. Below is my code replicating the above mappings. (except for the token chars part)

```
 var nGramFilters1 = new List<string> { "lowercase", "asciifolding", "nGram_filter" };
 var tChars = new List<string> { "letter", "digit", "punctuation", "symbol" };

    var createIndexResponse = client.CreateIndex(defaultIndex, c => c
                 .Settings(st => st
                 .Analysis(an => an
                 .Analyzers(anz => anz
                 .Custom("nGram_analyzer", cc => cc
                 .Tokenizer("whitespace").Filters(nGramFilters1)))
               .TokenFilters(tf=>tf.NGram("nGram_filter",ng=>ng.MinGram(2).MaxGram(20))))));

```

References:  
[SO Question](http://stackoverflow.com/questions/23374176/c-sharp-nest-elasticsearch-not-able-to-map-token-chars-to-nest-fluentmapping)  
[Github Issue](https://github.com/elastic/elasticsearch-net/pull/1012)

---

<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 5, 2017, 10:40pm UTC](https://discuss.elastic.co/t/token-chars-mapping-to-ngram-filter-elasticsearch-nest/54131/2 "2017-07-05T22:40:00Z")

</div>


