Moor: Any plan for FTS5 support

Created on 18 Oct 2019  路  4Comments  路  Source: simolus3/moor

I find that fts5: offline-full-text-search-in-android-ios and sqflite: fts5 support. FTS5 provide a very good way to do query.

Just wonder any plan on this?

dart-dsl enhancement generator

Most helpful comment

Thanks for the interesting article. As the referenced issue from sqflite mentions, FTS5 is not supported by the builtin sqlite interface from Android, so it won't be supported by moor_flutter either. Given that we probably won't support it universally, I don't think we should make higher-level apis for FTS5 tables or rankings available. We're probably not going to support them in the sqlparser either, so you'd have to use customSelect(...) manually.

In general, we could support them with moor_ffi though - we compile our own sqlite library for Android (and will probably do the same on iOS / macOS after Dart 2.6). I'm not sure if and how we can make this configurable, but we might be able to include FTS5 with that. I'm wondering how much larger the binary is with FTS5 enabled, maybe we can just turn it on by default (ICU extensions would be another interesting candidate).

All 4 comments

Thanks for the interesting article. As the referenced issue from sqflite mentions, FTS5 is not supported by the builtin sqlite interface from Android, so it won't be supported by moor_flutter either. Given that we probably won't support it universally, I don't think we should make higher-level apis for FTS5 tables or rankings available. We're probably not going to support them in the sqlparser either, so you'd have to use customSelect(...) manually.

In general, we could support them with moor_ffi though - we compile our own sqlite library for Android (and will probably do the same on iOS / macOS after Dart 2.6). I'm not sure if and how we can make this configurable, but we might be able to include FTS5 with that. I'm wondering how much larger the binary is with FTS5 enabled, maybe we can just turn it on by default (ICU extensions would be another interesting candidate).

With the next version of moor_ffi, we're going to support FTS5 on Android. It looks like iOS supports fts5 starting from iOS 11.

Revisiting my thoughts about a higher-level Dart api / sqlparser support for FTS5, I think moor should provide an api for it, but it shouldn't be imported by default. Similar to json1, importing another library (say package:moor/extensions/fts5.dart) and an optional build option could help here.

In the current state on develop, we support fts5 tables and queries in moor files. You can preview the documentation here. fts5 tables are declared with CREATE VIRTUAL TABLE statements. Queries on them also work like expected, with the MATCH operator, the rank column and all the fts5 functions.

At the moment, we don't have a Dart api for queries on fts5 tables - the sql syntax is a bit different so I'm not sure if it makes sense to provide Dart apis for that. In the next version of the generator, it will be possible to import Dart files into moor files without restrictions, so maybe this isn't even necessary.

fts5 support is available with moor 2.2 and moor_ffi 0.3.0. To create fts5 tables in moor files, you need to enable the extension in your build_options.yaml.

Let me know if you run into any problems, thanks!

Was this page helpful?
0 / 5 - 0 ratings