Unmarshal whole response into Raw field on Response for APIs that return fully dynamic format, like _mapping
This commit is contained in:
parent
36f0db102e
commit
589282a189
1
goes.go
1
goes.go
@ -352,6 +352,7 @@ func (req *Request) Run() (Response, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return Response{}, err
|
return Response{}, err
|
||||||
}
|
}
|
||||||
|
json.Unmarshal(body, &esResp.Raw)
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.api == "_bulk" && esResp.Errors {
|
if req.api == "_bulk" && esResp.Errors {
|
||||||
|
@ -172,6 +172,7 @@ func (s *GoesTestSuite) TestDeleteIndexExistingIndex(c *C) {
|
|||||||
|
|
||||||
expectedResponse := Response{}
|
expectedResponse := Response{}
|
||||||
expectedResponse.Acknowledged = true
|
expectedResponse.Acknowledged = true
|
||||||
|
resp.Raw = nil
|
||||||
c.Assert(resp, DeepEquals, expectedResponse)
|
c.Assert(resp, DeepEquals, expectedResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,6 +363,7 @@ func (s *GoesTestSuite) TestIndexWithFieldsInStruct(c *C) {
|
|||||||
Version: 1,
|
Version: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
response.Raw = nil
|
||||||
c.Assert(response, DeepEquals, expectedResponse)
|
c.Assert(response, DeepEquals, expectedResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,6 +428,7 @@ func (s *GoesTestSuite) TestIndexIdDefined(c *C) {
|
|||||||
Version: 1,
|
Version: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
response.Raw = nil
|
||||||
c.Assert(response, DeepEquals, expectedResponse)
|
c.Assert(response, DeepEquals, expectedResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,6 +498,7 @@ func (s *GoesTestSuite) TestDelete(c *C) {
|
|||||||
// XXX : even after a DELETE the version number seems to be incremented
|
// XXX : even after a DELETE the version number seems to be incremented
|
||||||
Version: 2,
|
Version: 2,
|
||||||
}
|
}
|
||||||
|
response.Raw = nil
|
||||||
c.Assert(response, DeepEquals, expectedResponse)
|
c.Assert(response, DeepEquals, expectedResponse)
|
||||||
|
|
||||||
response, err = conn.Delete(d, url.Values{})
|
response, err = conn.Delete(d, url.Values{})
|
||||||
@ -508,6 +512,7 @@ func (s *GoesTestSuite) TestDelete(c *C) {
|
|||||||
// XXX : even after a DELETE the version number seems to be incremented
|
// XXX : even after a DELETE the version number seems to be incremented
|
||||||
Version: 3,
|
Version: 3,
|
||||||
}
|
}
|
||||||
|
response.Raw = nil
|
||||||
c.Assert(response, DeepEquals, expectedResponse)
|
c.Assert(response, DeepEquals, expectedResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -567,6 +572,7 @@ func (s *GoesTestSuite) TestDeleteByQuery(c *C) {
|
|||||||
Id: "",
|
Id: "",
|
||||||
Version: 0,
|
Version: 0,
|
||||||
}
|
}
|
||||||
|
response.Raw = nil
|
||||||
c.Assert(response, DeepEquals, expectedResponse)
|
c.Assert(response, DeepEquals, expectedResponse)
|
||||||
|
|
||||||
//should be 0 docs after delete by query
|
//should be 0 docs after delete by query
|
||||||
@ -613,6 +619,7 @@ func (s *GoesTestSuite) TestGet(c *C) {
|
|||||||
Source: source,
|
Source: source,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
response.Raw = nil
|
||||||
c.Assert(response, DeepEquals, expectedResponse)
|
c.Assert(response, DeepEquals, expectedResponse)
|
||||||
|
|
||||||
fields := make(url.Values, 1)
|
fields := make(url.Values, 1)
|
||||||
@ -631,6 +638,7 @@ func (s *GoesTestSuite) TestGet(c *C) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
response.Raw = nil
|
||||||
c.Assert(response, DeepEquals, expectedResponse)
|
c.Assert(response, DeepEquals, expectedResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1070,6 +1078,7 @@ func (s *GoesTestSuite) TestUpdate(c *C) {
|
|||||||
Version: 1,
|
Version: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
response.Raw = nil
|
||||||
c.Assert(response, DeepEquals, expectedResponse)
|
c.Assert(response, DeepEquals, expectedResponse)
|
||||||
|
|
||||||
// Now that we have an ordinary document indexed, try updating it
|
// Now that we have an ordinary document indexed, try updating it
|
||||||
|
@ -88,6 +88,8 @@ type Response struct {
|
|||||||
ScrollId string `json:"_scroll_id"`
|
ScrollId string `json:"_scroll_id"`
|
||||||
|
|
||||||
Aggregations map[string]Aggregation `json:"aggregations,omitempty"`
|
Aggregations map[string]Aggregation `json:"aggregations,omitempty"`
|
||||||
|
|
||||||
|
Raw map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Represents an aggregation from response
|
// Represents an aggregation from response
|
||||||
|
Loading…
Reference in New Issue
Block a user