📚 effdsl - Awesome Go Library for Database Drivers

Elasticsearch query builder for Go
🏷️ Database Drivers
📂 Search and Analytic Databases
⭐ 0 stars
Detailed Description of effdsl
effdsl
effdsl is a composable Go DSL for building Elasticsearch queries and aggregations with type-safe options and predictable JSON output.
Key Features
- Type-safe query construction without raw JSON maps
- Functional options API for readable, composable queries
- Broad aggregation coverage (metrics, bucket, pipeline)
For details and examples, see the documentation.
Getting started
Install
With Go module support, add the import and Go will fetch dependencies automatically:
import "github.com/sdqri/effdsl/v2"
Or install directly:
go get -u github.com/sdqri/effdsl/v2
How to use
Start with effdsl.Define() and compose queries with options.
Examples
Raw JSON example
Example match query using a raw JSON string:
import (
es "github.com/elastic/go-elasticsearch/v8"
)
query := `{
"query": {
"match": {
"message": {
"query": "Hello World"
}
}
}
}`
res, err := es.Search(
es.Search.WithBody(strings.NewReader(query)),
)
Using effdsl
The same query using effdsl:
import (
es "github.com/elastic/go-elasticsearch/v8"
"github.com/sdqri/effdsl/v2"
mq "github.com/sdqri/effdsl/v2/queries/matchquery"
)
query, err := effdsl.Define(
effdsl.WithQuery(
mq.MatchQuery("message", "Hello World"),
),
)
res, err := es.Search(
es.Search.WithBody(strings.NewReader(query)),
)
For more examples and details on query parameters, visit the documentation.
Contributing
Contributions are welcome. Thanks for helping improve effdsl. 🤝 Please see CONTRIBUTING.md to get started.
License
This project is licensed under the MIT License. See LICENSE.md.