INNER CODE UNIT · Swift
getIndexPath
ZachNagengast/similarity-search-kit · Sources/SimilaritySearchKit/Core/Index/SimilarityIndex.swift:353
func getIndexPath(fromDirectory path: URL? = nil, name: String? = nil) throws -> URL? {
let indexName = name ?? self.indexName
let basePath: URL
if let specifiedPath = path {
basePath = specifiedPath
} else {
// Default local path
basePath = try getDefaultStoragePath()
}
return vectorStore.listIndexes(at: basePath).first(where: { $0.lastPathComponent.contains(indexName) })
}
private func getDefaultStoragePath() throws -> URL {
let appName = Bundle.main.bundleIdentifier ?? "SimilaritySearchKit"
let fileManager = FileManager.default
let appSupportDirectory = try fileManager.url(for: .applicationSupportDirectory, in: .userDomainMask, appropriateFor: nil, create: true)