From 19c83bfeff7ca44b3171c24bd80cd7253362326f Mon Sep 17 00:00:00 2001 From: Paul Bonser Date: Thu, 2 Feb 2017 18:44:49 -0600 Subject: [PATCH] fields no longer supported in 5.x --- goes_test.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/goes_test.go b/goes_test.go index cd0ba7c..58ea716 100644 --- a/goes_test.go +++ b/goes_test.go @@ -651,6 +651,7 @@ func (s *GoesTestSuite) TestGet(c *C) { } conn := NewClient(ESHost, ESPort) + version, _ := conn.Version() conn.DeleteIndex(indexName) _, err := conn.CreateIndex(indexName, map[string]interface{}{}) @@ -683,11 +684,6 @@ func (s *GoesTestSuite) TestGet(c *C) { response.Raw = nil c.Assert(response, DeepEquals, expectedResponse) - fields := make(url.Values, 1) - fields.Set("fields", "f1") - response, err = conn.Get(indexName, docType, docID, fields) - c.Assert(err, IsNil) - expectedResponse = &Response{ Status: 200, Index: indexName, @@ -700,6 +696,18 @@ func (s *GoesTestSuite) TestGet(c *C) { }, } + fields := make(url.Values, 1) + // The fields param is no longer supported in ES 5.x + if version < "5" { + fields.Set("fields", "f1") + } else { + expectedResponse.Source = map[string]interface{}{"f1": "foo"} + expectedResponse.Fields = nil + fields.Set("_source", "f1") + } + response, err = conn.Get(indexName, docType, docID, fields) + c.Assert(err, IsNil) + response.Raw = nil c.Assert(response, DeepEquals, expectedResponse) }