gpt4 book ai didi

elasticsearch - 在 Elasticsearch 和 Lucene 4.4 中使用 Shingles 和停用词

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

在我正在构建的索引中,我对运行查询感兴趣,然后(使用构面)返回该查询的带状疱疹。这是我在文本上使用的分析器:

{
"settings": {
"analysis": {
"analyzer": {
"shingleAnalyzer": {
"tokenizer": "standard",
"filter": [
"standard",
"lowercase",
"custom_stop",
"custom_shingle",
"custom_stemmer"
]
}
},
"filter": {
"custom_stemmer" : {
"type": "stemmer",
"name": "english"
},
"custom_stop": {
"type": "stop",
"stopwords": "_english_"
},
"custom_shingle": {
"type": "shingle",
"min_shingle_size": "2",
"max_shingle_size": "3"
}
}
}
}
}

主要问题是,在 Lucene 4.4 中,停止过滤器不再支持 enable_position_increments 参数来消除包含停用词的 shingles。相反,我会得到这样的结果......

“红色和黄色”

"terms": [
{
"term": "red",
"count": 43
},
{
"term": "red _",
"count": 43
},
{
"term": "red _ yellow",
"count": 43
},
{
"term": "_ yellow",
"count": 42
},
{
"term": "yellow",
"count": 42
}
]

自然地,这极大地扭曲了返回的带状疱疹的数量。在 Lucene 4.4 之后有没有一种方法可以在不对结果进行后处理的情况下管理它?

最佳答案

可能不是最佳解决方案,但最直接的方法是向您的分析器添加另一个过滤器以杀死“_”填充标记。在下面的示例中,我将其称为“kill_fillers”:

   "shingleAnalyzer": {
"tokenizer": "standard",
"filter": [
"standard",
"lowercase",
"custom_stop",
"custom_shingle",
"custom_stemmer",
"kill_fillers"
],
...

将“kill_fillers”过滤器添加到您的过滤器列表中:

"filters":{
...
"kill_fillers": {
"type": "pattern_replace",
"pattern": ".*_.*",
"replace": "",
},
...
}

关于elasticsearch - 在 Elasticsearch 和 Lucene 4.4 中使用 Shingles 和停用词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27410253/

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