gpt4 book ai didi

postgresql - elasticsearch ngram 和 postgresql trigram 搜索结果不匹配

转载 作者:行者123 更新时间:2023-11-29 12:17:28 26 4
gpt4 key购买 nike

我在 elasticsearch 上创建了一个索引,如下所示:

"settings" : {
"number_of_shards": 1,
"number_of_replicas": 0,
"analysis": {
"filter": {
"trigrams_filter": {
"type": "ngram",
"min_gram": 3,
"max_gram": 3
}
},
"analyzer": {
"trigrams": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase",
"trigrams_filter"
]
}
}
}
},
"mappings": {
"issue": {
"properties": {
"description": {
"type": "string",
"analyzer": "trigrams"
}
}
}
}

我的测试项目如下:

"alici onay verdi basarili satisiniz gerceklesti diyor ama hesabima para transferi gerceklesmemis"

"otomatik onay işlemi gecikmiş"

"************* nolu iade islemi urun kargoya verilmedi zamaninda iade islemlerinde urun erorr hata veriyor"

我用下面的查询测试了这个索引:

GET issue/_search
{
"query": {
"match": {
"description":{
"query": "otomatik onay istemi zamaninda gerceklesmemis"
}
}
}
}

结果:

{
....
"hits": {
....
"max_score": 2.3507352,
"hits": [
{
....
"_score": 2.3507352,
"_source": {
"issue_id": "*******",
"description": "alici onay verdi basarili satisiniz gerceklesti diyor ama hesabima para transferi gerceklesmemis"
}
}
]
}
}

但是 postgresql 上的相同数据使用以下 SQL 响应另一个结果:

SELECT 
public.tbl_issue_descriptions_big.description,
similarity(description, 'otomatik onay islemi zamaninda gerceklesmemis') AS sml
FROM
public.tbl_issue_descriptions_big
WHERE
description %'otomatik onay islemi zamaninda gerceklesmemis'
ORDER BY
sml DESC
LIMIT 10

结果是:

description                                           | sml
======================================================|======
otomatik onay islemi gecikmis |0,351852

为什么会造成这种差异?

最佳答案

我对 postgres 的了解不够,无法在那里给出合格的答案(因为这也取决于被索引的文档以及它们的评分公式是否完全相同,我对此表示怀疑),但 Elasticsearch 有一个 explain API和一个 explain parameter在搜索中,这可以帮助您找出为什么某个文档被这样评分。

关于postgresql - elasticsearch ngram 和 postgresql trigram 搜索结果不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45143583/

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