Easysearch、Elasticsearch 还是 Opensearch,是个问题

请教关于html_strip不管用的问题

Elasticsearch | 作者 solax | 发布于2017年04月28日 | 阅读数:6021

使用的版本是5.2.0应该是和现在最新的5.3.0一样的
 我想使用html_strip过滤HTML代码,但是不成功
我的操作步骤是这样的:
1.使用java代码创建了index,并且设置了setting
GET /aaasasn

-------------------

"settings": {
"index": {
"number_of_shards": "5",
"provided_name": "aaasasn",
"creation_date": "1493360822756",
"analysis": {
"analyzer": {
"my_analyzer": {
"char_filter": [
"my_char_filter"
],
"tokenizer": "standard"
}
},
"char_filter": {
"my_char_filter": {
"escaped_tags": [
"b"
],
"type": "html_strip"
}
}
},
"number_of_replicas": "1",
"uuid": "54N_yuSnSVigPVMCPujImw",
"version": {
"created": "5020099"
}
}
}

2.为特定字段mapping设置 analyzer :my_analyzer
查看结果如下:
没贴全 ,只贴了重点 
"aaasasn": {
"aliases": {},
"mappings": {
"test_bean": {
"properties": {
"content6": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"content7": {
"type": "text",
"analyzer": "my_analyzer"
},
3.查询,发现结果里面还是带有html代码
GET /aaasasn/_search
{
"query": {
"match": {
"content7": "我"
}
}
}

-----------------------------------------
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.2876821,
"hits": [
{
"_index": "aaasasn",
"_type": "test_bean",
"_id": "201",
"_score": 0.2876821,
"_source": {
"id": 201,
"name": "<input>content</input>",
"content7": "<p>我来看看</p>",
"remark": "12122",
"is_finished": true,
"test_bean2_id": 2
}
}
]
}
}

按照官网操作的,地址是
https://www.elastic.co/guide/e ... ut_20
 
 
求大大们能解答一下,被这东西弄的挺难受的
已邀请:

medcl - 今晚打老虎。

赞同来自: su_san zhaoxjmail

结果里面的标签是source,analyzer作用的是索引,你用analyze接口把这个带标签的内容测试一下,看看是不是能够正常过滤掉标签。

如果要原文过滤掉标签需要在ingest层处理。

solax - 砖工

赞同来自:

测试
------------------
POST aaasasn/_analyze
{
"analyzer": "my_analyzer",
"text": "<p>conte1nt</p>"
}
结果 
---------------
{
"tokens": [
{
"token": "conte1nt",
"start_offset": 3,
"end_offset": 11,
"type": "<ALPHANUM>",
"position": 0
}
]
}

heyK

赞同来自:

请问解决了么? 我也遇到这个问题不知道怎么解决

knownsec - 大数据方向研究

赞同来自:

感谢这篇文章,让我理解了分析器

guotenv

赞同来自:

ingest是怎么解决的呢~

要回复问题请先登录注册