Elasticsearch : Strip HTML tags before indexing docs with html_strip filter not working
<p><strong>Given</strong> I have specified my html strip char filter in my custom analyser</p>

<p><strong>When</strong> I index a document with html content</p>

<p><strong>Then</strong> I expect the html to be strip out of the indexed content</p>

<p><strong>And</strong> on retrieval the returned doc from the index shoult not contain hmtl
</p>

<p><strong>ACTUAL</strong>: 
The indexed doc contained html
The retrieved doc contained html</p>

<p>I have tried specifying the analyzer as index_analyzer as one would expect and a few others out of desperation search_analyzer and analyzer. Non seem to have any effect on the doc being indexed or retrieve.</p>

<h1>Test Doc Indexing against HTML_Strip Analysed field :</h1>

<p><strong>REQUEST : Example POST document with html content</strong></p>

<pre><code>POST /html_poc_v2/html_poc_type/02
{
  "description": "Description &lt;p&gt;Some d&amp;eacute;j&amp;agrave; vu &lt;a href=\"http://somedomain.com&gt;\"&gt;website&lt;/a&gt;",
  "title": "Title &lt;p&gt;Some d&amp;eacute;j&amp;agrave; vu &lt;a href=\"http://somedomain.com&gt;\"&gt;website&lt;/a&gt;",
  "body": "Body &lt;p&gt;Some d&amp;eacute;j&amp;agrave; vu &lt;a href=\"http://somedomain.com&gt;\"&gt;website&lt;/a&gt;"
}
</code></pre>

<p><em>Expected</em> : indexed data to have being parsed through the html analyser.
<em>Actual</em> : data is indexed with html</p>

<p><strong>RESPONSE</strong></p>

<pre><code>{
   "_index": "html_poc_v2",   "_type": "html_poc_type",   "_id": "02", ...
   "_source": {
      "description": "Description &lt;p&gt;Some d&amp;eacute;j&amp;agrave; vu &lt;a href=\"http://somedomain.com&gt;\"&gt;website&lt;/a&gt;",
      "title": "Title &lt;p&gt;Some d&amp;eacute;j&amp;agrave; vu &lt;a href=\"http://somedomain.com&gt;\"&gt;website&lt;/a&gt;",
      "body": "Body &lt;p&gt;Some d&amp;eacute;j&amp;agrave; vu &lt;a href=\"http://somedomain.com&gt;\"&gt;website&lt;/a&gt;"
   }
}
</code></pre>

<h1>Settings and Doc Mapping</h1>

<pre><code>PUT /html_poc_v2
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_html_analyzer": {
          "type": "custom",
          "tokenizer": "standard",
          "char_filter": [
            "html_strip"
          ]
        }
      }
    },
    "mappings": {
      "html_poc_type": {
        "properties": {
          "body": {
            "type": "string",
            "analyzer": "my_html_analyzer"
          },
          "description": {
            "type": "string",
            "analyzer": "my_html_analyzer"
          },
          "title": {
            "type": "string",
            "search_analyser": "my_html_analyzer"
          },
          "urlTitle": {
            "type": "string"
          }
        }
      }
    }
  }
}
</code></pre>

<h1>Test to proof Custom Analyser works perfectly:</h1>

<p><strong>REQUEST</strong></p>

<pre><code>GET /html_poc_v2/_analyze?analyzer=my_html_analyzer
{&lt;p&gt;Some d&amp;eacute;j&amp;agrave; vu &lt;a href="http://somedomain.com&gt;"&gt;website&lt;/a&gt;}
</code></pre>

<p><strong>Response</strong></p>

<pre><code>{
   "tokens": [
      {
         "token": "Some",… "position": 1
      },
      {
         "token": "déjà",… "position": 2
      },
      {
         "token": "vu",…  "position": 3
      },
      {
         "token": "website",… "position": 4
      }
   ]
}
</code></pre>

<h1>Under the hood</h1>

<p>going under the hood with an in-line script proofs further that my html analyser must have been skipped</p>

<p><strong>REQUEST</strong></p>

<pre><code>GET /html_poc_v2/html_poc_type/_search?pretty=true
{
  "query" : {
    "match_all" : { }
  },
  "script_fields": {
    "terms" : {
        "script": "doc[field].values",
        "params": {
            "field": "title"
        }
    }
  }
}
</code></pre>

<p><strong>RESPONSE</strong></p>

<pre><code>{ …
   "hits": { ..
      "hits": [
         {
            "_index": "html_poc_v2",
            "_type": "html_poc_type",
            …
            "fields": {
               "terms": [
                  [
                     "a",
                     "agrave",
                     "d",
                     "eacute",
                     "href",
                     "http",
                     "j",
                     "p",
                     "some",
                     "somedomain.com",
                     "title",
                     "vu",
                     "website"
                  ]
               ]
            }
         }
      ]
   }
}
</code></pre>

<p>Similar to this question here : <a href="https://stackoverflow.com/questions/28445684/why-html-tag-is-searchable-even-if-it-was-filtered-in-elastic-search">Why HTML tag is searchable even if it was filtered in elastic search</a> </p>

<p>I have also read this amazing doc : <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-htmlstrip-charfilter.html" rel="noreferrer">https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-htmlstrip-charfilter.html</a></p>

<p>ES version : 1.7.2</p>

<p>Please Help.</p>