Comments (4)
select simple_highlight(t1, 1, '[', ']') from t1 where t1 match simple_query('y列');
highlight 的第二个参数表示你想 select 的那一列的下标,下标从 0 开始;你这个例子如果想展示 y 列第二个参数就是 1
https://www.sqlite.org/fts5.html#the_highlight_function
另外如果你只想 match y 列可以这么写:
select simple_highlight(t1, 1, '[', ']') from t1 where y match simple_query('y列');
from simple.
select simple_highlight(t1, 1, '[', ']') from t1 where t1 match simple_query('y列');
highlight 的第二个参数表示你想 select 的那一列的下标,下标从 0 开始;你这个例子如果想展示 y 列第二个参数就是 1
https://www.sqlite.org/fts5.html#the_highlight_function
另外如果你只想 match y 列可以这么写:
select simple_highlight(t1, 1, '[', ']') from t1 where y match simple_query('y列');
我希望的效果是,还是用 t1 match simple_query('y列');,对于命中的结果,可以返回对应的列,只不是指定哪一列来显示,这有办法吗?
from simple.
做不到;这个和普通的 sql 原理是一样的, select 后面跟着哪些列是需要用户自己指定的,你也可以同时返回多个列:
select simple_highlight(t1, 0, '[', ']') , simple_highlight(t1, 1, '[', ']') from t1 where y match simple_query('y列');
但是不管怎么着都需要你自己指定。
有两种方法可以绕过这个问题,一个是通过 simple_highlight_pos 函数,这个函数会返回 match 的位置,判断返回是否为空,就知道这一列有没有 match 了
select simple_highlight_pos(t1, 0) , simple_highlight(t1, 1) from t1 where y match simple_query('y列');
另一种方法是类似这篇文章提到的,把需要索引的数据打平,然后再通过关联属性去查询是哪个字段命中了。
无论如何,sql select 只返回你指定的列这一点是改不了的
from simple.
明白了,非常感谢!!!
from simple.
Related Issues (20)
- simple_highlight_pos 内容有空格时候返回值不对 HOT 1
- 插件加载的时机? HOT 3
- windows下go的example运行报错: error during initialization: HOT 3
- 如何通过 simple_highlight_pos 获取全部的高亮?
- java HOT 1
- “找不到指定模块 ”错误 HOT 6
- 虚拟表字段声明UNINDEXED,会增加存储空间吗? HOT 6
- 支持pip install HOT 1
- Go Example运行问题 HOT 4
- 在electron上引入的时候,在几个用户电脑上会报DevTools was disconnected from the page. HOT 5
- 请问有arm64的插件包吗 HOT 20
- 关于stop_word HOT 1
- 添加一个基于SQLite.swift和本项目的demo,供大家参考 HOT 1
- no
- no such tokenize:simple HOT 1
- 错误匹配:查询“月明”会匹配到“明月” HOT 2
- windows x64包编译 HOT 2
- 能否加一个不使用 cmrc 的版本? HOT 2
- 增加flutter例子 HOT 2
- iOS加载动态库的问题 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simple.