esquery
esquery copied to clipboard
Consider support/compatibilty for Opensearch
This library currently depends on go-elasticsearch to implement some of the Search functionality. Without getting into a discussion on the opensearch/elasticsearch fork, what this libary accomplishes with the the query builder component is amazing! Makes writing queries so much better.
As a user of opensearch, I'd like to be able to continue to use esquery's Query builder.
Currently while I can accomplish this (code below) I suspect later updates may break it. I'd like to open a discussion on potentially maintaining this feature. I noticed Query returns a full Search object when it's marshaled into JSON, currently this seems to be overridden by the opensearch client/backend. But it'd be great if the integration was a bit cleaner.
client, err := opensearch.NewDefaultClient()
query := esquery.Query(
esquery.Bool().
Filter(
esquery.Range("@timestamp").Gt("now"),
)
)
searchResponse, err := client.Search(
client.Search.WithContext(ctx),
client.Search.WithIndex("foo"),
client.Search.WithBody(opensearchutil.NewJSONReader(&query)),
client.Search.WithSort("@timestamp:asc"),
)
Thank you for such a great library.
this fork works: https://github.com/certsio/esquery