elasticsearch-dsl

Version, currently master branch1 version
  • master branchlatestOct 8, 2018

github.com/newtonapple/elasticsearch-dsl.cr

A Crystal DSL for Elasticsearch

1 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  elasticsearch-dsl:
    github: newtonapple/elasticsearch-dsl.cr
    branch: master

master is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
0.26.1
License
MIT
Author
David Dai

Dependencies

This version declares no dependencies.

README

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