I am new to elasticsearch and was testing html_strip filter. Ideally I should not be able to search on HTML tags. Following is steps.
Index:
curl -XPOST 'localhost:9200/foo/test/_analyzer?tokenizer=standard&char_filters=html_strip' -d ' { "content" : "<title>Dilip Kumar</title>" }' Search:
http://localhost:9200/foo/test/_search?tokenizer=standard&char_filters=html_strip&q=title Result:
{ "took": 3, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 1, "max_score": 0.2169777, "hits": [ { "_index": "foo", "_type": "test", "_id": "_analyzer", "_score": 0.2169777, "_source": { "content": "<title>Dilip Kumar</title>" } } ] } } UPDATE As suggested; I used following mapping and repeated above steps after deleting the existing index however still I am able to search markup.
curl -XPUT "http://localhost:9200/foo " -d' { "foo": { "settings": { "analysis": { "analyzer": { "html_analyzer": { "type": "custom", "tokenizer": "standard", "filter": [ "standard", "lowercase", "stop", "asciifolding" ], "char_filter": [ "html_strip" ] }, "whitespace_analyzer": { "type": "custom", "tokenizer": "whitespace", "filter": [ "standard", "lowercase", "stop", "asciifolding" ] } } } }, "mappings": { "test": { "properties": { "content": { "type": "string", "index_analyzer": "html_analyzer", "search_analyzer": "whitespace_analyzer" } } } } } }'