CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.

ElastiQ 0.7.1

ElastiQ 0.7.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Sep 2017
SwiftSwift Version 4.0
SPMSupports SPM

Maintained by sgr-ksmt.



ElastiQ 0.7.1

  • By
  • Suguru Kishimoto

Generate ElasticSearch query in Swift

Feature

  • MethodChain
  • Type-Safe.
  • KeyPath compatible.

How to use

@objcMember
class Recipe: NSObject {
    dynamic var cookTimeMin: Int = 0
    dynamic var title: String = ""
}

let query = ElastiQ()
    .range(\Recipe.cookTimeMin, [.lt(30), .gte(10)])

let json = try! query.json()
print(String(data: json, encoding: .utf8))
//-------------------
{
  "query": {
    "range": {
      "cookTimeMin": {
        "gte":10,
        "lt":30
      }
    }
  }
}


let query = ElastiQ()
    .bool({ query in
        query.filter { filter in
            filter
                .term(\Recipe.title, "tomato")
                .range(\Recipe.cookTimeMin, .lt(30))
        }
    })

let json = try! query.json()
print(String(data: json, encoding: .utf8))
//----------------
{
  "query" : {
    "bool" : {
      "filter" : [
        {
          "term" : {
            "title" : "bean"
          }
        },
        {
          "range" : {
            "cookTimeMin" : {
              "lt" : 30
            }
          }
        }
      ]
    }
  }
}

TODO

  • [ ] from/size/source/field
  • [ ] match
  • [ ] aggregation
  • [ ] function score query

Requirements

  • iOS 9.0+
  • Xcode 9+
  • Swift 4+

Installation

Manually Install

Download all *.swift files and put your project.

Change log

Change log is here.

Communication

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.💪

License

ElastiQ is under MIT license. See the LICENSE file for more info.