mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-25 04:07:47 +00:00
Documentation
This commit is contained in:
1 parent
5abe72f7e7
commit
e4713edd75
1 file changed
+38
-4
@@ -9,13 +9,47 @@ GRDB lets you define your own custom FST5 tokenizers, and extend SQLite built-in
|
||||
- Have "first" match "1st"
|
||||
- Have "Encyclopaedia" match "Encyclopædia"
|
||||
- Have "Mueller" match "Müller", and "Grossman" match "Großmann"
|
||||
- Have "romaji" match "ローマ字"
|
||||
- Have "pinyin" match "拼音"
|
||||
- Prevent "the" and other stop words from matching any document
|
||||
|
||||
|
||||
## The Tokenizer Protocols
|
||||
|
||||
- **`FTS5Tokenizer`**: the protocol for all FTS5 tokenizers, including built-in tokenizers such as `ascii`, `unicode61`, and `porter`.
|
||||
|
||||
- **`FTS5CustomTokenizer`**: the low-level protocol for all custom tokenizers, close to the FTS5 metal.
|
||||
- [FTS5Tokenizer](#fts5tokenizer): the protocol for all FTS5 tokenizers, including built-in tokenizers such as `ascii`, `unicode61`, and `porter`.
|
||||
|
||||
- **`FTS5WrapperTokenizer`**: the high-level protocol for custom tokenizers that wrap an existing tokenizer, and post-processes its tokens.
|
||||
- [FTS5CustomTokenizer](#fts5customtokenizer): the low-level protocol for all custom tokenizers, close to the FTS5 metal.
|
||||
|
||||
- [FTS5WrapperTokenizer](#fts5wrappertokenizer): the high-level protocol for custom tokenizers that post-processes the tokens produced by another FTS5Tokenizer.
|
||||
|
||||
|
||||
## Using A Custom Tokenizer
|
||||
|
||||
Once you have a type that implements FTS5CustomTokenizer or FTS5WrapperTokenizer, you can create full-text tables that use it:
|
||||
|
||||
```swift
|
||||
class MyTokenizer : FTS5CustomTokenizer { ... }
|
||||
|
||||
try db.create(virtualTable: "documents", using: FTS5()) { t in
|
||||
t.tokenizer = MyTokenizer.tokenizerDescriptor()
|
||||
t.column("authors")
|
||||
t.column("title")
|
||||
t.column("body")
|
||||
}
|
||||
```
|
||||
|
||||
And then the full-text table can be fed and queried in a regular way:
|
||||
|
||||
```swift
|
||||
try Document(...).insert(db)
|
||||
let documents = Document.matching(...).fetchAll(db)
|
||||
```
|
||||
|
||||
## FTS5Tokenizer
|
||||
|
||||
|
||||
## FTS5CustomTokenizer
|
||||
|
||||
|
||||
## FTS5WrapperTokenizer
|
||||
|
||||
Reference in new issue
Block a user