postgrespro / rum

RUM access method - inverted index with additional information in posting lists
Other
721 stars 54 forks source link

[bug] the result is different when rum index(for tsquery) used and not used #123

Open miaojianxin opened 6 months ago

miaojianxin commented 6 months ago
  1. create table rules(id serial, keyword_rule tsquery);
  2. insert into rules(keyword_rule) values('( 实名举报 | 实名投诉 | 实名曝光 | 实名控诉 ) & !( 信用分 | 网上离婚 | 快速离婚 | 起诉离婚 | 考证 | 职称 | 免费咨询 | 一对一 | 提现 | 额度 | 专业 | 小说 | 离婚协议 | 追剧 | 好剧 | 短剧 | 知识 | 分享 | 保额 | 影视 | 代言 | 驾校 | 恭喜 | 高考 | 广告 | 国货 | 直播 | 二手 | 同城 | 如何 & ( 看待 | 避免 | 选择 | 导师 ) | 主播 | 说事 | 说新闻 | ( 纠纷 | 仲裁 | 考研 | 法律 ) & ( 咨询 | 专家 | 老师 ) | 汽车 & ( 服务 | 保养 | 美容 | 脚垫 ) | 转发 & 有需要 | 全集 | 房产人 | 上门 & 安装 )');
  3. select id from rules where to_tsvector('jiebaqry_golaxy','实名举报')@@keyword_rule; get result id:1
  4. create index idx_rum on rules using rum(keyword_rule);
  5. set enable_seqscan to FALSE ; ensure the rum index is used
  6. select get different resut exec sql: select id from rules where to_tsvector('jiebaqry_golaxy','实名举报')@@keyword_rule; get null.

result: the result is different when rum index(for tsquery) used and not used

miaojianxin commented 6 months ago

the tsquery rule can be simple like this: insert into rules(keyword_rule) values('( 实名举报 | 实名投诉 | 实名曝光 | 实名控诉 ) & !( 信用分 | (转发 & 有 需要))');

when rum index is used ,no result get for the sql: select id from rules where to_tsvector('jiebaqry_golaxy','实名举报')@@keyword_rule;

miaojianxin commented 6 months ago

simple the rule again: insert into rules (keyword_rule) values('实名举报 & !(转发&有需要)');
if keyword_rule like this , no result can get for the sql also

may be the problem is when ! and & used together