简体   繁体   English

如何在SQLite FTS3查询中转义-字符?

[英]How do I escape the - character in SQLite FTS3 queries?

I'm using Python and SQLAlchemy to query a SQLite FTS3 (full-text) store and I would like to prevent my users from using the - as an operator. 我正在使用Python和SQLAlchemy查询SQLite FTS3(全文)存储,但我想防止我的用户将-用作运算符。 How should I escape the - so users can search for a term containing the - (enabled by changing the default tokenizer) instead of it signifying "does not contain the term following the -"? 我应该如何转义-以便用户可以搜索包含-的术语(通过更改默认令牌生成器启用),而不是表示“不包含-后面的术语”?

From elsewhere on the internet it seems it may be possible to surround each search term with double quotes "some-term". 从互联网上的其他地方来看,似乎有可能在每个搜索词中都加上双引号“ some-term”。 Since we do not need the subtraction operation, my solution was to replace hyphens - with underscores _ when populating the search index and when performing searches. 因为我们不需要减法运算,我的解决办法是更换连字符-用下划线_填充搜索索引和执行搜索时的时候。

From this documentation it seems that it is not really possible. 本文档看来,这实际上是不可能的。 Try to replace your - with whitespace before searching… 在搜索之前,尝试用空格替换-

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM