Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否支持列过滤呢? #139

Open
yyzhiqiu opened this issue Nov 28, 2023 · 2 comments
Open

是否支持列过滤呢? #139

yyzhiqiu opened this issue Nov 28, 2023 · 2 comments
Labels
documentation Improvements or additions to documentation feature Used for auto generate changelog

Comments

@yyzhiqiu
Copy link

比如readme中的例子
select rowid as id, TITLE,CONTENT, simple_highlight(t1, 0, '[', ']') as title_highlighted, simple_highlight(t1, 1, '[', ']') as content_highlighted from t1 where t1 match simple_query('周杰伦')

如果我当前表t1 的结构为 serviceId tableName title content 多个列
我现在只想针对 title content 列进行全文检索,我试过使用sqlite中的柱过滤器,没办法实现
用 where 列1 match 值1 OR 列2 match 值2 的画 高亮又会有问题

希望有具体的方案和例子 谢谢

@wangfenjin wangfenjin added the feature Used for auto generate changelog label Nov 30, 2023
@wangfenjin
Copy link
Owner

按照这个 https://www.sqlite.org/fts5.html#fts5_column_filters 的描述,是可以根据列来搜索的,不过目前 simple_query() 这个函数确实不支持这个功能,需要开发

你可以考虑提 PR,也可以试一下其他方法,比如:

  1. 不使用 simple_query,自己拼接查询字符串。simple_query 是根据你的输入生成查询串,你可以看看 simple_query 这个函数的代码,或者根据官网自己写一个类似的函数
  2. 试一下比如 select rowid as id, TITLE,CONTENT, simple_highlight(t1, 0, '[', ']') as title_highlighted, simple_highlight(t1, 1, '[', ']') as content_highlighted from t1 where t1 match "title : " || simple_query('周杰伦') 也就是自己把只想搜索的列名拼到 simple_query 前面
  3. 不要给不想查询的列建全文索引。建表语句里面是可以指定哪些列要建索引的。看我在 readme 里面的两篇文章吧

@yyzhiqiu
Copy link
Author

感谢 我试了一下 第二种方法可以解决列过滤的问题,牛的 牛的 比如:
select rowid as id, TITLE,CONTENT, simple_highlight(t1, 0, '[', ']') as title_highlighted, simple_highlight(t1, 1, '[', ']') as content_highlighted from t1 where t1 match "{TITLE CONTENT} :" || simple_query('周杰伦')

@wangfenjin wangfenjin added the documentation Improvements or additions to documentation label Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature Used for auto generate changelog
Projects
None yet
Development

No branches or pull requests

2 participants