Swiftpack.co -  Package - meilisearch/meilisearch-swift
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
meilisearch/meilisearch-swift
Lightning Fast, Ultra Relevant, and Typo-Tolerant Search Engine Client written in Swift
.package(url: "https://github.com/meilisearch/meilisearch-swift.git", from: "v0.7.0")

MeiliSearch-Swift

MeiliSearch-Swift

MeiliSearch | Website | LinkedIn | Documentation | Slack | FAQ

GtiHub Workflow Status License Bors enabled

⚡ 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 an open-source search engine. Discover what MeiliSearch is! For more information about features go to our Swift documentation.

Features

  • Complete full API wrapper
  • Easy to install, deploy, and maintain
  • Highly customizable
  • No external dependencies
  • Thread safe
  • Uses Codable

Get started

Swift Package Manager

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")
]

Basic setup

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"
    }

}

Compatibility with MeiliSearch

This package only guarantees the compatibility with the version v0.20.0 of MeiliSearch.

Demo

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 or swift run in the terminal.

Vapor

Please check the Vapor Demo source code here.

Perfect

Please check the Perfect Demo source code here.

Development Workflow and Contributing

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!

Contact

Feel free to contact us about any questions you may have:

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.

GitHub

link
Stars: 52
Last commit: 1 week ago

Release Notes

v0.7.0 🕊
1 week ago

Breaking changes ⚠️

  • Update health method (#113) @curquiza

This version of this library makes it fully compatible with MeiliSearch v0.20.0.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco