From a9196feea3b664b23190881f640a1754f3e5602e Mon Sep 17 00:00:00 2001 From: Paul Bonser Date: Thu, 2 Feb 2017 18:11:37 -0600 Subject: [PATCH] Use DeleteByQuery in test --- goes_test.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/goes_test.go b/goes_test.go index f0e7e76..0643dbd 100644 --- a/goes_test.go +++ b/goes_test.go @@ -567,6 +567,8 @@ func (s *GoesTestSuite) TestDeleteByQuery(c *C) { docID := "1234" conn := NewClient(ESHost, ESPort) + version, _ := conn.Version() + // just in case conn.DeleteIndex(indexName) @@ -606,7 +608,13 @@ func (s *GoesTestSuite) TestDeleteByQuery(c *C) { c.Assert(err, IsNil) c.Assert(response.Hits.Total, Equals, uint64(1)) - response, err = conn.Query(query, []string{indexName}, []string{docType}, "DELETE", url.Values{}) + response, err = conn.DeleteByQuery(query, []string{indexName}, []string{docType}, url.Values{}) + + // There's no delete by query in ES 2.x + if version > "2" && version < "5" { + c.Assert(err, ErrorMatches, ".* does not support delete by query") + return + } c.Assert(err, IsNil) @@ -620,8 +628,12 @@ func (s *GoesTestSuite) TestDeleteByQuery(c *C) { } response.Raw = nil response.Shards = Shard{} + response.Took = 0 c.Assert(response, DeepEquals, expectedResponse) + _, err = conn.RefreshIndex(indexName) + c.Assert(err, IsNil) + //should be 0 docs after delete by query response, err = conn.Search(query, []string{indexName}, []string{docType}, url.Values{}) c.Assert(err, IsNil)