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

Enable fts (full text search) for Deno-sqlite #108

Closed
dyedgreen opened this issue Mar 7, 2021 · 15 comments · Fixed by #251
Closed

Enable fts (full text search) for Deno-sqlite #108

dyedgreen opened this issue Mar 7, 2021 · 15 comments · Fixed by #251
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested

Comments

@dyedgreen
Copy link
Owner

I've just run into this too. I was trying to load the fts5 extension.

(Originally posted by @hobochild in #100 (comment) )

Full text search seems like a common problem and it might make sense to enable full text search by default (since there is currently no way to import extensions at run-time). But I wanted to see how many others are interested in this functionality. (It it turns out to be too niche, it might make sense to ask people to compile their own WASM module with the extension enabled.)

For reference: SQLite full text search docs

@dyedgreen dyedgreen added enhancement New feature or request help wanted Extra attention is needed question Further information is requested labels Mar 7, 2021
@artisonian
Copy link

I'd like to see fts5 support by default. What about rtree (considering it is also available in the sqlite CLI)?

@dyedgreen
Copy link
Owner Author

Hm. I would be curious to test how much each feature effects the WASM binary size vs how much they are used to better understand the tradeoffs involved.

It might also be interesting to offer some more documentation on how to compile your own version if you have specific needs.

@artisonian
Copy link

artisonian commented Mar 10, 2021

This is anecdotal, but I ran deno info after enabling fts5 and rtree:

https://deno.land/x/[email protected]/build/sqlite.js (810.68KB)
file:///src/vendor/deno-sqlite/build/sqlite.js (1.03MB)

And fts5 alone:

file:///src/vendor/deno-sqlite/build/sqlite.js (1018.54KB)

dhardtke added a commit to dhardtke/prandium that referenced this issue Mar 25, 2021
The plan is to update this feature in the future once dyedgreen/deno-sqlite#108 is resolved to enable a real full-text search.
@dyedgreen
Copy link
Owner Author

A thought on loading sqlite extensions: with Deno.dlopen it is possible to run code from a shared object. I’m not sure how much memory sharing SQLite extensions require; but if it’s sufficiently little (we can’t really easily expose the WASM memory to a so I believe), it might be possible to run arbitrary SQLite extensions.

@iuioiua
Copy link

iuioiua commented Nov 14, 2021

Having fts supported would be amazing. Are there any workarounds in the meantime?

@lusbuab
Copy link

lusbuab commented Nov 20, 2021

@ashersaupingomez

Having fts supported would be amazing. Are there any workarounds in the meantime?

You'd need to compile the WASM module yourself with the necessary build options enabled. https://www.sqlite.org/fts5.html should include all necessary information.

@mdkq
Copy link

mdkq commented Mar 15, 2022

Any update on this? I'm having no problem with a custom build with fts5 enabled but would prefer not to have the repo sitting in my project

@dyedgreen
Copy link
Owner Author

I've had some thoughts around using denos dll loader / a wash loader set-up to support loading custom extensions, but I don't have any specific progress on that yet.

@EtienneK
Copy link

+1 for this feature. It is something I really need.

@teleclimber
Copy link
Contributor

It might also be interesting to offer some more documentation on how to compile your own version if you have specific needs.

I think this would be welcome at this point. It seems some people were able to enable fts without too much trouble. Perhaps @artisonian would be willing to publish his changes? I took a look at doing this myself but I'm quickly out of my depth.

A maintained fork or branch with commonly requested configurations could be one way to address this.

Thanks!

@alexgleason
Copy link
Contributor

@mdkq Can you share the commands you're using to build SQLite and use it with this library?

@teleclimber
Copy link
Contributor

@alexgleason You can fork this repo, make the changes to the config, and let Github actions build it for you. See the commits I made on my fork:

https://github.com/teleclimber/deno-sqlite

Then you can import it directly from Github:

import { DB } from "https://github.com/teleclimber/deno-sqlite/raw/master/mod.ts";

const db = new DB();

db.execute(`
CREATE VIRTUAL TABLE posts 
USING FTS5(title, body)
`);

//.. more FTS5 fun

Feel free to us mine to experiment with, but I make zero promises to keep it up to date right now (and it's already behind).

@alexgleason
Copy link
Contributor

@teleclimber Fantastic, thank you!!!

@alexgleason
Copy link
Contributor

Well, FTS works awesome with @teleclimber's fork. I'm even using it with Kysely query builder and it's wonderful.

@dyedgreen Would you be open to merging 05ce37d? I can make a pull request.

@dyedgreen
Copy link
Owner Author

I think this is probably fine; I’d like to check if this extension is also enabled in nodes better sqlite but fts5 seems useful enough that we can enable it by default 😄

alexgleason added a commit to alexgleason/deno-sqlite that referenced this issue Aug 31, 2023
alexgleason added a commit to alexgleason/deno-sqlite that referenced this issue Aug 31, 2023
dyedgreen pushed a commit that referenced this issue Sep 3, 2023
* Enable full-text search (FTS5)
Fixes #108

* Alphabetize compile flags, add a comment about SQLITE_ENABLE_FTS5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants