云数据库 GAUSSDB-相似文档排序召回检索函数和操作符:gs_bm25_distance_textarr

时间:2024-11-13 14:46:10

gs_bm25_distance_textarr

功能说明:返回bm25文档相似分数,只在使用BM25索引检索时有效。

入参类型:text[], text[]

出参类型:double precision

代码示例
-- 建表及BM25索引
gaussdb=# CREATE TABLE st_information (st_id SERIAL PRIMARY KEY, st_name TEXT[], st_email TEXT[]);
gaussdb=# CREATE INDEX st_information_st_email_bm25_index ON st_information USING bm25(st_email);
-- 执行检索
gaussdb=# SELECT /*+ indexscan(st_information, st_information_st_email_bm25_index) */ *, gs_bm25_distance_textarr(st_email, '{common-domain@xyz.com}') AS score FROM st_information ORDER BY st_email ### '{common-domain@xyz.com}' desc LIMIT 10;
support.huaweicloud.com/centralized-devg-v8-gaussdb/gaussdb-42-1682.html