title: Creating a custom analyzer with Nest (for email address)
body: <p>I have a class with a <code>UserID</code> field which contains a mail address, and I would like to be able to search on that field either for an exact match, or for parts of the mail address with some exclusions.  </p>
  
  <p>For example, if <code>UserID</code> contains "john.doe@foo.com", I would like to be able to search for "john.doe@foo.com", "john" and "doe", but "foo" and "com" should be excluded from the indexing.</p>
  
  <p>I've tried to create a custom analyzer which uses a stop filter with a list of excluded words, and then apply a multi index to the property as in this example:</p>
  
  <pre><code>using Nest;
  using System;
  using System.Collections.Generic;
  
  [ElasticType]
  public class ElasticUser {
      [ElasticProperty(Index = FieldIndexOption.NotAnalyzed)]
      public string UserID { get; set; }
  }
  
  class Program {
  
      static void Main(string[] args) {
          const string IndexName = "test_index";
  
          var settings = new ConnectionSettings(uri: new Uri("http://localhost:9200/"), defaultIndex: IndexName);
          var client = new ElasticClient(settings);
  
          // delete the index for the test
          var deleteIndexResp = client.DeleteIndex(IndexName);
  
          // create the custom filter and analyzer
          var user_id_stop_filter = new StopTokenFilter {
              Stopwords = new[] { "foo", "bar", "com" }
          };
          var user_id_analyzer = new CustomAnalyzer {
              Filter = new List&lt;string&gt; {
                  "user_id_stop_filter"
              },
              Tokenizer = "letter"
          };
  
          // create the index with the custom filter and analyzer
          var createIndexResp = client.CreateIndex(IndexName, index =&gt; index
              .Analysis(analysis =&gt; analysis
                  .TokenFilters(t =&gt; t
                      .Add("user_id_stop_filter", user_id_stop_filter))
                  .Analyzers(a =&gt; a
                      .Add("user_id_analyzer", user_id_analyzer))));
  
          // add a mapping for the "ElasticUser" type
          var putMapResp = client.Map&lt;ElasticUser&gt;(
              m =&gt; m.MapFromAttributes()
              .Properties(properties =&gt; properties
                  .MultiField(multi =&gt; multi
                      .Name(p =&gt; p.UserID)
                      .Fields(fields =&gt; fields
                          .String(s =&gt; s
                              .Name(p =&gt; p.UserID)
                              .Index(FieldIndexOption.NotAnalyzed)
                          )
                          .String(s =&gt; s
                              .Name(p =&gt; p.UserID.Suffix("searchable"))
                              .Analyzer("user_id_analyzer")
                          )
                      )
                  )
              ));
  
          // add a couple of entries
          client.Index(new ElasticUser {
              UserID = "some.one@foo.com"
          });
          client.Index(new ElasticUser {
              UserID = "another.one@bar.com"
          });
      }
  
  }
  </code></pre>
  
  <p>However, this does not seem to work, as I can only search for exact matches, but email addresses are not tokenized splitting on non-words.</p>
  
  <p>How can I get this multi-index to work as described?</p>
  
  <p>When I try to run this query, I'm not getting any results:</p>
  
  <pre><code>GET /test_index/elasticuser/_search
  {
      "query": {
          "query_string": {
             "query": "one"
          }
      }
  }
  </code></pre>