Swiftpack.co - Package - meilisearch/meilisearch-swift

MeiliSearch-Swift

MeiliSearch-Swift

MeiliSearch | Website | Blog | LinkedIn | Twitter | Documentation | FAQ

Build Status License Slack

⚡ 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.

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.15.0 of MeiliSearch.

Demo

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: 38

Dependencies

Used By

Total: 0

Releases

v0.4.0 🕊 - 2020-10-08 16:05:37

Breaking changes ⚠️

  • Remove acceptNewFields routes (#51) @Ethenyl
  • Change search method from get to post (#30) @bidoubiwa

Thanks again to @Ethenyl, @bidoubiwa, and @curquiza. Special thanks to @ppamorim who improved all the tests! 🎉

v0.3.0 🕊 - 2020-10-01 14:32:32

Changes

Breaking changes ⚠️

  • Remove sys-info routes (#50) @Ethenyl
  • Add primaryKey during index creation (#32) @bidoubiwa and @ppamorim
  • name is optional in Index struct (#32) @bidoubiwa and @ppamorim

Fixes

  • Fix updateDocuments method (#32) @bidoubiwa and @ppamorim
  • Use the apiKey when requesting (#32) @bidoubiwa and @ppamorim
  • Fix deleteBatch method (#32) @bidoubiwa and @ppamorim
  • Fix updateIndex method (#32) @bidoubiwa and @ppamorim

Thanks again to @Ethenyl, @bidoubiwa, @curquiza and @ppamorim! 🎉

v0.2.0 🕊 - 2020-07-30 09:07:43

Changes

  • MeiliSearch bump to v0.13.0 (#28) @curquiza
  • Add release drafter (#17) @curquiza
  • Add CONTRIBUTING.md (#19) @curquiza
  • Update github actions to not run the documentation action when opening a PR (#23) @ppamorim
  • Update swift-test.yml to run it on every PR, not only pointing to master (#27) @curquiza
  • Feature/facets (#16) @ppamorim

Breaking changes

  • Rename addOrReplaceDocument and addOrUpdateDocument into addDocuments and updateDocuments. (#21) @curquiza

Thanks again to @curquiza, @eskombro and @ppamorim! 🎉

0.1.0 - 2020-06-22 04:07:31

First version of meilisearch-swift.

This release contains:

  • Support to version v0.10.X of Meilisearch;
  • Support to Index, Document, Search, Updates, Keys, Settings, Stats, Health, Version and System Information.