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

fts5 syntax error when using punctuation #651

Closed
clausjuhl opened this issue Dec 18, 2019 · 2 comments
Closed

fts5 syntax error when using punctuation #651

clausjuhl opened this issue Dec 18, 2019 · 2 comments
Labels

Comments

@clausjuhl
Copy link

@clausjuhl clausjuhl commented Dec 18, 2019

Hi Simon

I get a syntax error when using punctuation or special characters in a fulltext search (using fts5). I created the virtual table using sqlite-utils' "enable-fts"-command.

The same error appears on Niche Museums https://www.niche-museums.com/browse/search?q=park., but works fine in most of your other datasette-examples, e.g. register-of-members-interests https://register-of-members-interests.datasettes.com/regmem-98dc8b7/items?_search=mins.

What am I doing wrong? Many thanks!

@simonw

This comment has been minimized.

Copy link
Owner

@simonw simonw commented Dec 22, 2019

I've not yet been able to figure out what the escaping rule are for FTS5 queries.

If we figure out how those work maybe we can bundle them as a custom function?

select ... where docs_fts match fts_escape(:search)
@simonw

This comment has been minimized.

Copy link
Owner

@simonw simonw commented Dec 22, 2019

https://stackoverflow.com/a/43756146 says that an escaping mechanism that works is this one:

select * from blah where term match '"bacon" "and" "eggs"'

So split on whitespace and then encapsulate each search term in double quotes.

@simonw simonw added feature small and removed bug help wanted labels Dec 22, 2019
simonw added a commit to simonw/museums that referenced this issue Dec 29, 2019
@simonw simonw closed this in 3c861f3 Dec 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.