The elasticsearch html_strip character filter doesn't work as expected with query_search query
You didn't define any field in your query. By default, it hits all fields include description, and description.keyword.
When you trying with match query you are defining the fields :).
Update query like the following
GET /test_html_strip/_search
{
  "query": {
    "query_string": {
      "query": "<html>",
      "fields": ["description"]
    }
  }
}


The behaviour of html_strip character filter looks different with the search query using "query_string" and "match" query.

Created index with "description" field using my_analyzer having html_strip char filter

{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_analyzer": {
          "tokenizer": "standard",
          "char_filter": [
            "html_strip"
          ]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "description": {
        "type": "text",
        "analyzer": "my_analyzer"
      }
    }
  }
}


Indexed as below with sample html content

PUT test_index/_doc/001
{
  "description": "<html><body>Hello world</body></html>"
}

document created.

search using <html> :


GET /test_index/_search
{
  "query": {
    "query_string": {
      "query": "<html>"
    }
  }
}

Expecting no hits as the html contents would be stripped out internally when using html_strip character filter as per the document (https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-htmlstrip-charfilter.html) but got the result,
result:
{
    "took": 2,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 1,
            "relation": "eq"
        },
        "max_score": 0.2876821,
        "hits": [
            {
                "_index": "test_index",
                "_type": "_doc",
                "_id": "001",
                "_score": 0.2876821,
                "fields": {
                    "description": [
                        "<html><body>Hello world</body></html>"
                    ]
                }
            }
        ]
    }
}

Returns the record (ideally it should not).

Let's search using "match" query:

When match query is used it could not find a record when searched using <html> or <body>. whereas it returns record when searched using "Hello" which seems to be the right behaviour of html_strip char filter.
GET /test_index/_search
{
    "query": {
    "match": {
      "description": "<html>"
    }
  },
  "fields": [
    "description"
  ],
   "_source": false
}

Result:
{
    "took": 2,
    "timed_out": false,
    "_shards": {
        "total": 1,
        "successful": 1,
        "skipped": 0,
        "failed": 0
    },
    "hits": {
        "total": {
            "value": 0,
            "relation": "eq"
        },
        "max_score": null,
        "hits": []
    }
}

the above query doesn't return any result and looks like the html_strip character filter is working fine with "match" query.
Any suggestions why html_strip character filter is not working as expected with "query_string" query and working with "match" query?
Am I missing anything here?
