Skip to content

Commit

Permalink
Release 7.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
olivere committed Oct 6, 2019
1 parent 2046010 commit a4c3e84
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 96 deletions.
Binary file removed .edit.swp
Binary file not shown.
78 changes: 0 additions & 78 deletions .golangci.yml

This file was deleted.

26 changes: 16 additions & 10 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

const (
// Version is the current version of Elastic.
Version = "7.0.6"
Version = "7.0.7"

// DefaultURL is the default endpoint of Elasticsearch on the local machine.
// It is used e.g. when initializing a new Client without a specific URL.
Expand Down Expand Up @@ -97,6 +97,9 @@ var (

// noRetries is a retrier that does not retry.
noRetries = NewStopRetrier()

// noDeprecationLog is a no-op for logging deprecations.
noDeprecationLog = func(*http.Request, *http.Response) {}
)

// Doer is an interface to perform HTTP requests.
Expand All @@ -117,12 +120,13 @@ type Client struct {
conns []*conn // all connections
cindex int // index into conns

mu sync.RWMutex // guards the next block
urls []string // set of URLs passed initially to the client
running bool // true if the client's background processes are running
errorlog Logger // error log for critical messages
infolog Logger // information log for e.g. response times
tracelog Logger // trace log for debugging
mu sync.RWMutex // guards the next block
urls []string // set of URLs passed initially to the client
running bool // true if the client's background processes are running
errorlog Logger // error log for critical messages
infolog Logger // information log for e.g. response times
tracelog Logger // trace log for debugging
deprecationlog func(*http.Request, *http.Response)
scheme string // http or https
healthcheckEnabled bool // healthchecks enabled or disabled
healthcheckTimeoutStartup time.Duration // time the healthcheck waits for a response from Elasticsearch on startup
Expand Down Expand Up @@ -245,6 +249,7 @@ func NewSimpleClient(options ...ClientOptionFunc) (*Client, error) {
sendGetBodyAs: DefaultSendGetBodyAs,
gzipEnabled: DefaultGzipEnabled,
retrier: noRetries, // no retries by default
deprecationlog: noDeprecationLog,
}

// Run the options on it
Expand Down Expand Up @@ -330,6 +335,7 @@ func DialContext(ctx context.Context, options ...ClientOptionFunc) (*Client, err
sendGetBodyAs: DefaultSendGetBodyAs,
gzipEnabled: DefaultGzipEnabled,
retrier: noRetries, // no retries by default
deprecationlog: noDeprecationLog,
}

// Run the options on it
Expand Down Expand Up @@ -1386,7 +1392,7 @@ func (c *Client) PerformRequest(ctx context.Context, opt PerformRequestOptions)

// Log deprecation warnings as errors
if len(res.Header["Warning"]) > 0 {
logDeprecation((*http.Request)(req), res)
c.deprecationlog((*http.Request)(req), res)
for _, warning := range res.Header["Warning"] {
c.errorf("Deprecation warning: %s", warning)
}
Expand Down Expand Up @@ -1483,9 +1489,9 @@ func (c *Client) Reindex() *ReindexService {

// TermVectors returns information and statistics on terms in the fields
// of a particular document.
func (c *Client) TermVectors(index, typ string) *TermvectorsService {
func (c *Client) TermVectors(index string) *TermvectorsService {
builder := NewTermvectorsService(c)
builder = builder.Index(index).Type(typ)
builder = builder.Index(index)
return builder
}

Expand Down
2 changes: 1 addition & 1 deletion setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func setupTestClient(t logger, options ...ClientOptionFunc) (client *Client) {

// Log deprecations during tests
if loglevel := *logDeprecations; loglevel != "off" {
logDeprecation = func(req *http.Request, res *http.Response) {
client.deprecationlog = func(req *http.Request, res *http.Response) {
for _, warning := range res.Header["Warning"] {
if !*logTypesRemoval && strings.Contains(warning, "[types removal]") {
continue
Expand Down
3 changes: 0 additions & 3 deletions termvectors.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,6 @@ func (s *TermvectorsService) Validate() error {
if s.index == "" {
invalid = append(invalid, "Index")
}
if s.typ == "" {
invalid = append(invalid, "Type")
}
if len(invalid) > 0 {
return fmt.Errorf("missing required fields: %v", invalid)
}
Expand Down
8 changes: 4 additions & 4 deletions termvectors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestTermVectorsBuildURL(t *testing.T) {
}

for _, test := range tests {
builder := client.TermVectors(test.Index, test.Type)
builder := client.TermVectors(test.Index).Type(test.Type)
if test.Id != "" {
builder = builder.Id(test.Id)
}
Expand Down Expand Up @@ -81,7 +81,7 @@ func TestTermVectorsWithId(t *testing.T) {

// TermVectors by specifying ID
field := "Message"
result, err := client.TermVectors(testIndexName, "_doc").
result, err := client.TermVectors(testIndexName).
Id("1").
Fields(field).
FieldStatistics(true).
Expand Down Expand Up @@ -115,7 +115,7 @@ func TestTermVectorsWithDoc(t *testing.T) {
"fullname": "keyword",
}

result, err := client.TermVectors(testIndexName, "_doc").
result, err := client.TermVectors(testIndexName).
Doc(doc).
PerFieldAnalyzer(perFieldAnalyzer).
FieldStatistics(true).
Expand Down Expand Up @@ -149,7 +149,7 @@ func TestTermVectorsWithFilter(t *testing.T) {
"fullname": "keyword",
}

result, err := client.TermVectors(testIndexName, "_doc").
result, err := client.TermVectors(testIndexName).
Doc(doc).
PerFieldAnalyzer(perFieldAnalyzer).
FieldStatistics(true).
Expand Down

0 comments on commit a4c3e84

Please sign in to comment.