• Stars
    star
    197
  • Rank 197,722 (Top 4 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created about 3 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Strongly typed Elasticsearch DSL written in Rust

Strongly typed Elasticsearch DSL written in Rust

Crates.io Crates.io Crates.io Docs.io Rust

A high level library, giving a strongly typed DSL that maps one to one with the official Elasticsearch query DSL.

Features

  • Strongly typed queries
  • Strongly typed aggregations
  • Strongly typed completions
  • Response structures
  • Automatically skips empty queries making DSL pleasant to use
  • Crate doesn't depend on elasticsearch-rs and can be used as a standalone library with any HTTP client to call Elasticsearch

Installation

Add elasticsearch-dsl crate and version to Cargo.toml

[dependencies]
elasticsearch-dsl = "0.4"

Documentation

Documentation for the library is available on docs.rs

Quick start

use elasticsearch_dsl::*;

fn main() {
    let query = Search::new()
        .source(false)
        .stats("statistics")
        .from(0)
        .size(30)
        .query(
            Query::bool()
                .must(Query::multi_match(
                    ["title", "description"],
                    "you know, for search",
                ))
                .filter(Query::terms("tags", ["elasticsearch"]))
                .should(Query::term("verified", true).boost(10)),
        )
        .aggregate(
            "country_ids",
            Aggregation::terms("country_id")
                .aggregate("catalog_ids", Aggregation::terms("catalog_id"))
                .aggregate("company_ids", Aggregation::terms("company_id"))
                .aggregate(
                    "top1",
                    Aggregation::top_hits()
                        .size(1)
                        .sort(FieldSort::ascending("user_id")),
                ),
        )
        .rescore(Rescore::new(Query::term("field", 1)).query_weight(1.2));
}
{
  "_source": false,
  "stats": ["statistics"],
  "from": 0,
  "size": 30,
  "query": {
    "bool": {
      "must": [
        {
          "multi_match": {
            "fields": ["title", "description"],
            "query": "you know, for search"
          }
        }
      ],
      "filter": [{ "terms": { "tags": ["elasticsearch"] } }],
      "should": [{ "term": { "verified": { "value": true, "boost": 10.0 } } }]
    }
  },
  "aggs": {
    "country_ids": {
      "terms": { "field": "country_id" },
      "aggs": {
        "catalog_ids": { "terms": { "field": "catalog_id" } },
        "company_ids": { "terms": { "field": "company_id" } },
        "top1": {
          "top_hits": {
            "size": 1,
            "sort": [{ "user_id": { "order": "asc" } }]
          }
        }
      }
    }
  },
  "rescore": [
    {
      "query": {
        "rescore_query": { "term": { "field": { "value": 1 } } },
        "query_weight": 1.2
      }
    }
  ]
}

See examples for more.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

More Repositories

1

sidekiq-pool

Sidekiq::Pool allows Sidekiq using more CPU cores on Ruby MRI by forking multiple processes.
Ruby
41
star
2

rest-dhcpd

REST driven DHCP server
Go
22
star
3

elasticsearch-exporter-rs

Proper Elasticsearch exporter
Rust
22
star
4

packwerk-intellij

Runs Packwerk in the background and adds error annotations to Ruby source files.
Kotlin
16
star
5

certificator

A tool that requests certificates from ACME supporting CA, solves DNS challenges, and stores retrieved certificates in Vault.
Go
14
star
6

preferx

A reactive SharedPreferences library for Kotlin
Kotlin
13
star
7

kafka-connect-vespa

Kafka Connect Vespa sink connector
Java
12
star
8

flink-big-query-connector

Flink connector for BigQuery
Java
12
star
9

actioncable-client-kotlin

Ruby WebSockets implementation (Action Cable) client library for Kotlin.
Kotlin
11
star
10

S3Grabber

Service that periodically extracts data from S3 (if needed) and calls a list of commands with a given shell
Go
11
star
11

sbomsftw

Tool for SBOM (Software Bill Of Materials) collection from filesystems & GitHub repositories.
Go
10
star
12

xmlsec

Ruby bindings for xmlsec
C
7
star
13

sonic-exporter

sonic-exporter is prometheus exporter for network switches running sonic NOS.
Go
7
star
14

kafka-elasticsearch-tool

CLI tool that helps working with Elasticsearch and Kafka
Clojure
6
star
15

ab

Determines which ab test and variant identifier belongs to
Ruby
6
star
16

chef-proxysql

Chef ProxySQL cookbook with auto loading and comprehensive configuration
Ruby
6
star
17

dotpay

dotpay.pl gem
Ruby
5
star
18

chef-vitess

Chef cookbook for Vitess database clustering system.
Ruby
5
star
19

cucumber-specs

Cucumber specification steps for testing Apache Spark applications
Scala
5
star
20

interactor-initializer

Dry interactor initializer
Ruby
4
star
21

chained_job

Ruby
4
star
22

sql_fingerprint

Abstracts SQL query and calculates fingerprint
Ruby
4
star
23

coper

Android runtime permissions with Coroutines
Kotlin
4
star
24

postfix-exporter

Postfix exporter for Prometheus
Go
3
star
25

vmemcached-rs

Rust memcached client
Rust
3
star
26

chef-clickhouse

Chef cookbook for ClickHouse database
Ruby
3
star
27

luks-tools

Tools for automating LUKS drive unlocking, kdump collection.
Go
3
star
28

pronto-rails_migrations

Ruby
2
star
29

jenkins-nitro

Analyze Jenkins test duration changes between builds and pinpoint the slowdowns
Ruby
2
star
30

request_local_cache

Ruby
2
star
31

vgo-picker-iOS

Vinted GO Picker for iOS
Swift
2
star
32

chef-orchestrator

Ruby
2
star
33

sre_academy

SRE academy
Ruby
2
star
34

vinted-logger-rs

Vinted logger for Rust applications
Rust
2
star
35

sinatra-error-logger

Sinatra error logging middleware
Ruby
1
star
36

vinted-ab-ios

Vinted ab testing framework for iOS
Swift
1
star
37

VGHtmlParser

A simple html parser
HTML
1
star
38

py-safestats

Python
1
star
39

ab-java

Java
1
star
40

vinted-prometheus-client-mmap

Forked prometheus-client-mmap gem
Rust
1
star
41

airbrake-graylog2

Send Airbrake exceptions to Graylog2
Ruby
1
star
42

ceph-exporter

Prometheus exporter for Ceph
Go
1
star
43

kafka-ui-serde

Custom Kafka UI serializers and deserializers
Java
1
star