Latest 0.7.1
Homepage https://github.com/sgr-ksmt/ElastiQ
License MIT
Platforms ios 9.0, requires ARC
Authors

Generate ElasticSearch query in Swift

GitHub release
Language
Carthage Compatible
CocoaPods
CocoaPodsDL

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

Carthage

  • Add the following to your Cartfile:
github "sgr-ksmt/ElastiQ" ~> 0.7.1
  • Run carthage update
  • Add the framework as described.

    Details: Carthage Readme

CocoaPods

ElastiQ is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'ElastiQ', '~> 0.7.1'

and run pod install

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.:muscle:

License

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

Latest podspec

{
    "name": "ElastiQ",
    "version": "0.7.1",
    "summary": "Generate ElasticSearch query in Swift",
    "homepage": "https://github.com/sgr-ksmt/ElastiQ",
    "license": "MIT",
    "authors": {
        "Suguru Kishimoto": "melodydance.k.s@gmail.com"
    },
    "source": {
        "git": "https://github.com/sgr-ksmt/ElastiQ.git",
        "tag": "0.7.1"
    },
    "platforms": {
        "ios": "9.0"
    },
    "requires_arc": true,
    "source_files": "Sources/**/*",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This