gpt4 book ai didi

elasticsearch - Elastic Search 中的 HTML Strip

转载 作者:行者123 更新时间:2023-11-29 02:44:42 24 4
gpt4 key购买 nike

我有一个文档,其属性包含 html 标签。我想在索引之前删除 html

我找到了这个 htmlstrip-charfilter但我找不到使用它的例子。我是 Elasticsearch 和分析器概念的新手。

谢谢

最佳答案

请检查以下链接:

# Analyze text: "the <b>quick</b> bröwn <img src="fox"/> &quot;jumped&quot;"

curl -XPUT 'http://127.0.0.1:9200/foo/' -d '
{
"index" : {
"analysis" : {
"analyzer" : {
"test_1" : {
"char_filter" : [
"html_strip"
],
"tokenizer" : "standard"
},
"test_2" : {
"filter" : [
"standard",
"lowercase",
"stop",
"asciifolding"
],
"char_filter" : [
"html_strip"
],
"tokenizer" : "standard"
}
}
}
}
}
'

curl -XGET 'http://127.0.0.1:9200/foo/_analyze?format=text&text=the+%3Cb%3Equick%3C%2Fb%3E+br%C3%B6wn+%3Cimg+src%3D%22fox%22%2F%3E+%26quot%3Bjumped%26quot%3B&analyzer=standard'

# "tokens" : "[b:5->6:<ALPHANUM>]
#
# 3:
# [quick:7->12:<ALPHANUM>]
#
# 4:
# [b:14->15:<ALPHANUM>]
#
# 5:
# [bröwn:17->22:<ALPHANUM>]
#
# 6:
# [img:24->27:<ALPHANUM>]
#
# 7:
# [src:28->31:<ALPHANUM>]
#
# 8:
# [fox:33->36:<ALPHANUM>]
#
# 9:
# [quot:41->45:<ALPHANUM>]
#
# 10:
# [jumped&quot:46->57:<COMPANY>]
# "
# }

curl -XGET 'http://127.0.0.1:9200/foo/_analyze?format=text&text=the+%3Cb%3Equick%3C%2Fb%3E+br%C3%B6wn+%3Cimg+src%3D%22fox%22%2F%3E+%26quot%3Bjumped%26quot%3B&analyzer=test_1'

# {
# "tokens" : "[the:0->3:<ALPHANUM>]
#
# 2:
# [quick:7->12:<ALPHANUM>]
#
# 3:
# [bröwn:17->22:<ALPHANUM>]
#
# 4:
# [jumped:46->52:<ALPHANUM>]
# "
# }

curl -XGET 'http://127.0.0.1:9200/foo/_analyze?format=text&text=the+%3Cb%3Equick%3C%2Fb%3E+br%C3%B6wn+%3Cimg+src%3D%22fox%22%2F%3E+%26quot%3Bjumped%26quot%3B&analyzer=test_2'

# {
# "tokens" : "[quick:7->12:<ALPHANUM>]
#
# 3:
# [brown:17->22:<ALPHANUM>]
#
# 4:
# [jumped:46->52:<ALPHANUM>]
# "
# }

https://gist.github.com/clintongormley/780895

感谢克林顿 Gorm 利

关于elasticsearch - Elastic Search 中的 HTML Strip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18780346/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com