2
我是elasticsearch的新手,并且正在测试html_strip过滤器。理想情况下,我不应该搜索HTML标签。以下是步骤。为什么HTML标签可以搜索,即使它被弹性搜索过滤
指数:
curl -XPOST 'localhost:9200/foo/test/_analyzer?tokenizer=standard&char_filters=html_strip' -d '
{
"content" : "<title>Dilip Kumar</title>"
}'
搜索:
http://localhost:9200/foo/test/_search?tokenizer=standard&char_filters=html_strip&q=title
结果:
{
"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 作为建议;我使用下面的映射并在删除现有索引后重复上述步骤,但仍然可以搜索标记。
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"
}
}
}
}
}
}'
我没有得到你。我也在索引上应用了char_filters = html_strip。我是elasticsearch的新手......无法弄清楚你的观察结果。同时我正在阅读如何根据您分享的文档创建映射。 – joy 2015-02-11 08:17:29
我使用了映射,但仍然是相同的问题。更新后添加映射详细信息。敬请期待。 – joy 2015-02-11 08:39:03
我已经更新了答案 – 2015-02-11 10:41:59