cjimti / esquerydsl

Safely create complex ES Search Queries via the Query DSL in golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

build GoDoc

ES Query DSL

Structs and marshal-ers that help wrangle writing elastic search queries using the ES query DSL spec

Installation

go get github.com/mottaquikarim/esquerydsl

Usage

playground

package main

import (
	"fmt"

	"github.com/mottaquikarim/esquerydsl"
)

func main() {
	_, body, _ := esquerydsl.GetQueryBlock(esquerydsl.QueryDoc{
		Index: "some_index",
		Sort:  []map[string]string{map[string]string{"id": "asc"}},
		And: []esquerydsl.QueryItem{
			esquerydsl.QueryItem{
				Field: "some_index_id",
				Value: "some-long-key-id-value",
				Type:  "match",
			},
		},
	})
	fmt.Println(body)
	// {"query":{"bool":{"must":[{"match":{"some_index_id":"some-long-key-id-value"}}]}},"sort":[{"id":"asc"}]}
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Run Tests

make test

Format

make fmt

Lint

make lint

License

MIT

About

Safely create complex ES Search Queries via the Query DSL in golang

License:MIT License


Languages

Language:Go 86.0%Language:Makefile 14.0%