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

Multiple Search Handles > Single View #548

Open
dezinezync opened this issue Apr 22, 2021 · 0 comments
Open

Multiple Search Handles > Single View #548

dezinezync opened this issue Apr 22, 2021 · 0 comments

Comments

@dezinezync
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant