MeiliSearch | Website | Blog | LinkedIn | Twitter | Documentation | FAQ
⚡ Lightning Fast, Ultra Relevant, and Typo-Tolerant Search Engine MeiliSearch client written in Swift 🍎
MeiliSearch-Swift is a client for MeiliSearch written in Swift. MeiliSearch is a powerful, fast, open-source, easy to use and deploy search engine. Both searching and indexing are highly customizable. Features such as typo-tolerance, filters, and synonyms are provided out-of-the-box. For more information about features go to our Swift documentation.
- Complete full API wrapper
- Easy to install, deploy, and maintain
- Highly customizable
- No external dependencies
- Thread safe
- Uses Codable
The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift
compiler.
Once you have your Swift package set up, adding MeiliSearch-Swift as a dependency is as easy as adding it to the dependencies
value of your Package.swift
.
dependencies: [
.package(url: "https://github.com/meilisearch/meilisearch-swift.git")
]
Make sure to firstly setup your MeiliSearch
server. Please follow this getting started here.
To do a simply search using the client, you can create a Swift script like this:
import MeiliSearch
func searchForMovies() {
// Create a new client instance of MeiliSearch with the default host.
let client = try! MeiliSearch()
// Create a new search request with "botman" as query.
let searchParameters = SearchParameters.query("botman")
// Typealias that represents the result from Meili.
typealias MeiliResult = Result<SearchResult<Movie>, Swift.Error>
// Call the function search and wait for the closure result.
self.client.search(UID: "movies", searchParameters) { (result: MeiliResult) in
switch result {
case .success(let searchResult):
print(searchResult)
case .failure(let error):
print(error)
}
}
}
private struct Movie: Codable, Equatable {
let id: Int
let title: String
let poster: String
let overview: String
let releaseDate: Date
enum CodingKeys: String, CodingKey {
case id
case title
case poster
case overview
case releaseDate = "release_date"
}
}
This package only guarantees the compatibility with the version v0.16.0 of MeiliSearch.
To try out a demo you will need to go to its directory in Demos/
. In that directory you can either:
- Open the SwiftPM project in Xcode and press run, or
- Run
swift build
orswift run
in the terminal.
Please check the Vapor Demo source code here.
Please check the Perfect Demo source code here.
Any new contribution is more than welcome in this project!
If you want to know more about the development workflow or want to contribute, please visit our contributing guidelines for detailed instructions!
Feel free to contact us about any questions you may have:
- At bonjour@meilisearch.com: English or French is welcome! 🇬🇧 🇫🇷
- Via the chat box available on every page of our documentation and on our landing page.
- Join our Slack community.
- By opening an issue.
Any suggestion or feedback is highly appreciated. Thank you for your support!
Swift programming language from Apple
MeiliSearch provides and maintains many SDKs and Integration tools like this one. We want to provide everyone with an amazing search experience for any kind of project. If you want to contribute, make suggestions, or just know what's going on right now, visit us in the integration-guides repository.