Giter Site home page Giter Site logo

Comments (4)

wangfenjin avatar wangfenjin commented on May 31, 2024
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.

lyyyann avatar lyyyann commented on May 31, 2024
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.

wangfenjin avatar wangfenjin commented on May 31, 2024

做不到;这个和普通的 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列');

另一种方法是类似这篇文章提到的,把需要索引的数据打平,然后再通过关联属性去查询是哪个字段命中了。

liuyqxkim0

无论如何,sql select 只返回你指定的列这一点是改不了的

from simple.

lyyyann avatar lyyyann commented on May 31, 2024

明白了,非常感谢!!!

from simple.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.