综合编程

appbase-swift: A Lightweight Swift Client for ElasticSearch

微信扫一扫,分享到朋友圈

appbase-swift: A Lightweight Swift Client for ElasticSearch
0

W e’re excited to officially announce appbase-swift , a lightweight ElasticSearch/appbase.io client for Swift. Making it easier than ever to build a great search experience for iOS and Mac platforms.

Why Did We Build It

Similar to the companion library we announced recently for Android, we first set out to create appbase-swift as there were no well-maintained ElasticSearch clients out there for Swift. This remains true even today.

We have kept these design goals in mind:

  1. Provide a lightweight library for querying right from iOS apps as well as Mac apps.
  2. Only focus on document and search APIs. We hope you aren’t planning to update your cluster settings from a mobile app :wink:. Ideally, you are using a hosted environment likeappbase.io which provides granular security controls.

Getting Started

It’s really easy to get started with it.

If you don’t already have an ElasticSearch index (called an app in appbase.io), you can create one for free fromappbase.io dashboard.


Next, we will use the app and the API credentials to instantiate the client.

let client = Client.init(url: ELASTICSEARCH_URL, app: APPNAME, credentials: CREDENTIALS)

Once we have the client instantiated, we can then use the index, update, and search methods. For example, a search method call would look like this:

let body:[String:Any] = [
    "query": [
        "match": [
            "title": "The Young Messiah"
        ]
    ]
];
client.search(type: "SwiftClientES", body: body,completionHandler: { (json, response, error) in
    var json = json as! Dictionary<String, Any>
    json = json["hits"] as? Dictionary<String, Any> ?? [:]
    print(json)
})

The auto-generated docs are available overhere. You can also checkout the quickstart for the client over here . Here’s an example app showing the usage of the client.


Image: Demo repository showing the above app
https://github.com/harsh-2711/SwiftElasticSearchDemo

The client is licensed under Apache 2.0 . We welcome :wave: contributions.

  • We’re working next on adding a declarative UI component for building a search bar for iOS Apps.
  • We’re also working on adding direct support for recording search analytics from the client, making it easier to understand how your end-users are using search and the business ROI from it.


Image: appbase.io dashboard showing search analytics

阅读原文...


Avatar

Vim/Neovim Arbitrary Code Execution Via Modelines (CVE-2002-1377, CVE-2016-1248, CVE-2019-1...

上一篇

Using Keep-Alives To Ensure Long-Running MySQL & MariaDB Sessions Stay Connected

下一篇

您也可能喜欢

评论已经被关闭。

插入图片
appbase-swift: A Lightweight Swift Client for ElasticSearch

长按储存图像,分享给朋友