esquery icon indicating copy to clipboard operation
esquery copied to clipboard

Consider support/compatibilty for Opensearch

Open dekimsey opened this issue 2 years ago • 1 comments

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.

dekimsey avatar Apr 20 '22 21:04 dekimsey

this fork works: https://github.com/certsio/esquery

lc avatar Aug 24 '23 18:08 lc