title: Custom phonetic analysis in Elasticsearch
body: <p>In our service we are trying to port a customization of the "nysiis" phonetic algorithm to Elasticsearch.</p>
  
  <p>Our algorithm performs this name transformation:</p>
  
  <blockquote>
    <p>given a list of "Surnames" and "Firstnames", such as "[Smith]" and
    "[John]", takes the "nysiis" phonetic encoder on the first surname,
    and concatenates it to the lowercase first initial of the first
    firstname.</p>
  </blockquote>
  
  <p>Hence:</p>
  
  <pre><code>nysiis(Surnames[0]) + lower(Firstnames[0][0])
  </code></pre>
  
  <p>So the result with "John Smith" would be "SNATHj"</p>
  
  <p>I know ES supports the nyyis token filter <a href="https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-phonetic-token-filter.html" rel="nofollow">https://www.elastic.co/guide/en/elasticsearch/plugins/current/analysis-phonetic-token-filter.html</a></p>
  
  <p>but I wonder what is the best way to implement a custom analyzer that automatically perform the above transformation.</p>
  
  <hr>
  
  <p>Note: I guess, if needed, we can already provide ES with a simple structure:</p>
  
  <pre><code>{"surname": "Smith", "initial_first_name": "j"}
  </code></pre>