From 5761bdcd5d364e534bbf1941d19d58a3308afcaa Mon Sep 17 00:00:00 2001 From: Roman Date: Thu, 22 Sep 2022 15:04:03 +0300 Subject: [PATCH] Support Elasticsearch v8 --- README.md | 6 +++--- count.go | 4 ++-- custom.go | 4 ++-- delete.go | 4 ++-- es.go | 4 ++-- go.mod | 4 ++-- go.sum | 6 ++++-- search.go | 8 ++------ 8 files changed, 19 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 7e0eea7..c172dbd 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ This is an early release, API may still change. `esquery` is a Go module. To install, simply run this in your project's root directory: ```bash -go get github.com/aquasecurity/esquery +go get github.com/aquasecurity/esquery/v8 ``` ## Usage @@ -51,8 +51,8 @@ import ( "context" "log" - "github.com/aquasecurity/esquery" - "github.com/elastic/go-elasticsearch/v7" + "github.com/aquasecurity/esquery/v8" + "github.com/elastic/go-elasticsearch/v8" ) func main() { diff --git a/count.go b/count.go index 2e01b5c..43f70ab 100644 --- a/count.go +++ b/count.go @@ -4,8 +4,8 @@ import ( "bytes" "encoding/json" - "github.com/elastic/go-elasticsearch/v7" - "github.com/elastic/go-elasticsearch/v7/esapi" + "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v8/esapi" ) // CountRequest represents a request to get the number of matches for a search diff --git a/custom.go b/custom.go index 17186cf..35d0fad 100644 --- a/custom.go +++ b/custom.go @@ -1,8 +1,8 @@ package esquery import ( - "github.com/elastic/go-elasticsearch/v7" - "github.com/elastic/go-elasticsearch/v7/esapi" + "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v8/esapi" ) // CustomQueryMap represents an arbitrary query map for custom queries. diff --git a/delete.go b/delete.go index 4e5163d..dc50bf8 100644 --- a/delete.go +++ b/delete.go @@ -4,8 +4,8 @@ import ( "bytes" "encoding/json" - "github.com/elastic/go-elasticsearch/v7" - "github.com/elastic/go-elasticsearch/v7/esapi" + "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v8/esapi" ) // DeleteRequest represents a request to ElasticSearch's Delete By Query API, diff --git a/es.go b/es.go index 4149a01..e896e60 100644 --- a/es.go +++ b/es.go @@ -32,8 +32,8 @@ // "context" // "log" // -// "github.com/aquasecurity/esquery" -// "github.com/elastic/go-elasticsearch/v7" +// "github.com/aquasecurity/esquery/v8" +// "github.com/elastic/go-elasticsearch/v8" // ) // // func main() { diff --git a/go.mod b/go.mod index d17acbf..f066982 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,9 @@ -module github.com/aquasecurity/esquery +module github.com/aquasecurity/esquery/v8 go 1.13 require ( - github.com/elastic/go-elasticsearch/v7 v7.6.0 + github.com/elastic/go-elasticsearch/v8 v8.4.0 github.com/fatih/structs v1.1.0 github.com/jgroeneveld/schema v1.0.0 // indirect github.com/jgroeneveld/trial v2.0.0+incompatible diff --git a/go.sum b/go.sum index fae67ff..cd26fbd 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ -github.com/elastic/go-elasticsearch/v7 v7.6.0 h1:sYpGLpEFHgLUKLsZUBfuaVI9QgHjS3JdH9fX4/z8QI8= -github.com/elastic/go-elasticsearch/v7 v7.6.0/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4= +github.com/elastic/elastic-transport-go/v8 v8.1.0 h1:NeqEz1ty4RQz+TVbUrpSU7pZ48XkzGWQj02k5koahIE= +github.com/elastic/elastic-transport-go/v8 v8.1.0/go.mod h1:87Tcz8IVNe6rVSLdBux1o/PEItLtyabHU3naC7IoqKI= +github.com/elastic/go-elasticsearch/v8 v8.4.0 h1:Rn1mcqaIMcNT43hnx2H62cIFZ+B6mjWtzj85BDKrvCE= +github.com/elastic/go-elasticsearch/v8 v8.4.0/go.mod h1:yY52i2Vj0unLz+N3Nwx1gM5LXwoj3h2dgptNGBYkMLA= github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/jgroeneveld/schema v1.0.0 h1:J0E10CrOkiSEsw6dfb1IfrDJD14pf6QLVJ3tRPl/syI= diff --git a/search.go b/search.go index 5c661a2..adad2f9 100644 --- a/search.go +++ b/search.go @@ -6,8 +6,8 @@ import ( "fmt" "time" - "github.com/elastic/go-elasticsearch/v7" - "github.com/elastic/go-elasticsearch/v7/esapi" + "github.com/elastic/go-elasticsearch/v8" + "github.com/elastic/go-elasticsearch/v8/esapi" ) // SearchRequest represents a request to ElasticSearch's Search API, described @@ -26,7 +26,6 @@ type SearchRequest struct { sort Sort source Source timeout *time.Duration - } // Search creates a new SearchRequest object, to be filled via method chaining. @@ -113,8 +112,6 @@ func (req *SearchRequest) Highlight(highlight Mappable) *SearchRequest { return req } - - // Map implements the Mappable interface. It converts the request to into a // nested map[string]interface{}, as expected by the go-elasticsearch library. func (req *SearchRequest) Map() map[string]interface{} { @@ -155,7 +152,6 @@ func (req *SearchRequest) Map() map[string]interface{} { m["search_after"] = req.searchAfter } - source := req.source.Map() if len(source) > 0 { m["_source"] = source