A full text search class using sqlite FTS5 as the text indexer
@objc public class DSFFullTextSearchIndex: NSObject
NSObject
@objc public func add(document: Document, useNativeEnumerator: Bool = false, stopWords: Set<String>? = nil) -> Status
Add a new document to the search index
@objc public func add(url: URL, text: String, canReplace: Bool = true, useNativeEnumerator: Bool = false, stopWords: Set<String>? = nil) -> Status
- url: The unique URL identifying the document
- text: The document text
- canReplace: Allow or disallow replacing a document with an identical URL
- useNativeEnumerator: If true, uses the native text enumerator methods to split into words before adding to index. Can improve word searching for CJK texts
- stopWords: If set, removes any words in the set from the document before adding to the index
true if the document was successfully added to the index, false otherwise
@objc public func add(documents: [Document], canReplace _: Bool = true, useNativeEnumerator: Bool = false, stopWords: Set<String>? = nil) -> Status
Run the provided block within a search index transaction.
@objc public func inTransaction(block: () -> Status) -> Status
Remove the specified document from the search index
@objc public func remove(url: URL) -> Status
Remove the specified documents from the search index
@objc public func remove(urls: [URL]) -> Status
Remove all documents in the search index
@objc public func removeAll() -> Status
Returns true if the specified document url exists in the search index, false otherwise
@objc public func exists(url: URL) -> Bool
Returns all the document URLs stored in the index
@objc public func allURLs() -> [URL]
Returns the number of documents in the search index
@objc public func count() -> Int32
Perform a text search using the current index
@objc public func search(text: String) -> [URL]?
- text: The text to search for
An array of document URLs matching the text query