A Crystal DSL for Elasticsearch
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
benchmark
spec
src
.editorconfig
.gitignore
.travis.yml
LICENSE
README.md
shard.yml

README.md

elasticsearch-dsl

A Crystal DSL for Elasticsearch. It is partially inspired by the Ruby Elasticsearch DSL.

WARNING:

THIS LIBRARY IS A WORK IN PROGRESS & API IS A MOVING TARGET.

Installation

Add this to your application's shard.yml:

dependencies:
  elasticsearch-dsl:
    github: newtonapple/elasticsearch-dsl

Usage

require "elasticsearch-dsl"

include Elasticsearch::DSL::Search
include Queries

bool_query = search {
  query {
    bool {
      must(MultiMatch) {
        fields ["title^2", "description", "body"]
        query "metaprogramming"
      }
      should(MatchPhrase) {
        match_phrase("body") {
          query "crystal magic"
        }
      }
    }
  }
}

puts bool_query.to_pretty_json
# =>
# {
#   "query": {
#     "bool": {
#       "must": {
#         "multi_match":{
#           "fields": ["title^2", "description", "body"],
#           "query": "metaprogramming"
#         }
#       },
#       "should": {
#         "match_phrase": {
#           "body": {
#             "query": "crystal magic"
#           }
#         }
#       }
#     }
#   }
# }

Please see spec for more examples.

Contributors