在SQLite FTS中,首先要有确切的短语吗? [英] Exact phrase first before anything else in SQLite FTS?

查看:127
本文介绍了在SQLite FTS中,首先要有确切的短语吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设搜索输入为是什么".这将匹配无论是什么",也将匹配什么是",这是确切的短语.现在,如何在排序中首先使确切的短语呢?

Suppose the search input is 'what is'. This will match 'whatever it is' and also 'what is' which is the exact phrase. Now, how do I make the exact phrase first in the sorting?

从昨天开始,我一直在考虑这个问题,并且我继续提出不同的解决方案,但是每种解决方案都有其自身的缺陷.

I've been thinking about this since yesterday and I keep on coming up with different solutions but each has somehow its own flaw.

这是我失败的方法(假设输入='what is'):

Here are my failed approach though (supposing input = 'what is'):

SELECT snippet(fts), 1 as rank
FROM fts
WHERE body MATCH '"what is"'
UNION ALL
SELECT snippet(fts), 2 as rank
FROM fts
WHERE body MATCH 'what* NEAR/3 is*' -- 3 is arbitrary
ORDER BY rank

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆