-
Notifications
You must be signed in to change notification settings - Fork 365
Description
I'm theorising my solution for implementing Full Text Search, and I had a few questions to ensure my understanding of the module is correct.
Full Disclosure; I have not tried writing or experimenting with any code.
Models
I have two distinct model objects which I need to index for using with YapDB's FTS module.
struct Foo {
let identifier: String
let title: String
let keywords: [String]
}
struct Bar {
let identifier: String
let title: String
let author: String
let summary: String?
}A distinct merged struct can be created from the above like so:
enum SearchableType {
case Foo
case Bar
}
struct Searchable {
let identifier: String
let title: String
let keywords: [String]?
let author: String?
let summary: String?
let type: SearchableType
}View
For my search view, I need to show both matching types (Foo and Bar) based on the user's input.
Question
As per the documentation for FTS, the YapDatabaseFullTextSearch initialiser takes a columns argument with propertiesToIndex as its value.
In my case, title and identifier are the only common property across the two models. What the documentation is unclear about are conditional values for the columns.
A: Assuming that conditional values are unsupported (i.e. the FTS module would not like NULL values in these columns), should I create two separate handlers and YapDatabaseFullTextSearch extensions for each struct (and forego the merged struct)?
B: If conditional values are supported, do I need to take additional care when writing the queries for fetching results? Repurposing one of the examples from the documentation:
// struct.author matches: john
// struct.summary contains phrase: "board meeting"
query = "author:john summary:\"board meeting\""
ftsTransaction.enumerateKeysAndObjects(matching: query) { (collection, key, obj, stop) in
// ...
}Does the FTS module take care of only looking at non-NULL values in its table? Or do I need to modify the above query to explicitly tell it to skip over NULL values?