# How to add auto complete feature on an Attachment fields while search- Elastic search (NEST)

**URL:** <https://discuss.elastic.co/t/how-to-add-auto-complete-feature-on-an-attachment-fields-while-search-elastic-search-nest/53666>\
**Category:** Elasticsearch\
**Created:** [June 22, 2016, 2:08pm UTC](https://discuss.elastic.co/t/how-to-add-auto-complete-feature-on-an-attachment-fields-while-search-elastic-search-nest/53666 "2016-06-22T14:08:31Z")\
**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 22, 2016, 2:08pm UTC](https://discuss.elastic.co/t/how-to-add-auto-complete-feature-on-an-attachment-fields-while-search-elastic-search-nest/53666/1 "2016-06-22T14:08:31Z")

</div>

1. I would like to add autocomplete feature to my search application which fetches documents based on the search query. Can some one help me how this can be done on an attachment fields like content and title fields. (completion suggester)  
Here are my class and their mappings.

`Mapping and creating index:`

```
var createIndexResponse =
                           client.CreateIndex(defaultIndex, c => c
                           .Mappings(m => m
                           .Map<Document>(mp => mp
                           .Properties(ps => ps
                               .String(s => s.Name(e => e.Title))
                               .Attachment(s => s.Name(p => p.File)
                                   .FileField(ff => ff.Name(f => f.File) .TermVector(TermVectorOption.WithPositionsOffsetsPayloads)
                                   .Analyzer("english")
                                   .Store(true)))))));

```

1. And also can we use multiple analyzers on the same field? because I'm already using english analyzer on my content so that it will look for all the possibilities(like if I search for property, it will check for properties etc ) of the search term and then generate results. If I want to add auto complete feature, then I need to either use edgeNgram or Ngram . Is it possible to do so along side english analyzer? (Few of the examples used N-grams for analyzing, but I'm afraid that I might loose the advantages of English analyzer if I use N-gram )

TIA

## EDIT

I was trying to change the mappings and create an analyzer to store the content as edge\_ngram

```
   var fullNameFilters = new List<string> { "lowercase","edge_ngram_analyzer"};
    var createIndexResponse =
                   client.CreateIndex(defaultIndex, c => c
                   .Settings(st=>st
                   .Analysis(anl=>anl
                   .Analyzers(anz=>anz
                   .Custom("edge_ngram_analyzer", ff=>ff.Filters(fullNameFilters).Tokenizer("standard")))))
                   .Mappings(m => m
                   .Map<Document>(mp => mp
                   .Properties(ps => ps
                       .String(s => s.Name(e => e.Title).Analyzer("autocomplete"))                          
                       .Attachment(s => s.Name(p => p.File)
                           .FileField(ff => ff.Name(f => f.File)
                           .TermVector(TermVectorOption.WithPositionsOffsetsPayloads)
                           .Analyzer("english")
                           .Store(true)))))));

```

I'm not able to add the filters part for the analyzer I have used. I want to replicate as something like below.

```
{ 
  "settings": { 
    "analysis": { 
      "filter": { 
        "myNGramFilter": {
          "type": "edgeNGram",
          "min_gram": 1,
          "max_gram": 40 
      }}, 
      "analyzer": { 
        "myNGramAnalyzer": { 
          "type": "custom",
          "tokenizer": "standard",
          "filter": ["lowercase", "myNGramFilter"]
      }}}},

```

How can I add the filter part for the same.

---

<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/how-to-add-auto-complete-feature-on-an-attachment-fields-while-search-elastic-search-nest/53666/3 "2017-07-05T22:40:46Z")

</div>


