Skip to content

Commit

Permalink
GOCBC-1111: On status 200 parse any search errors from the status object
Browse files Browse the repository at this point in the history
Motivation
-----------
Search can reply with a status code of 200 but still have errors which
are recorded in the status object. At present we try to parse these
errors from the top level object instead.

Changes
--------
Update search response json parsing so that the errors field is parsed
from within the status object.

Change-Id: I2e4caaf5ee955fba04b9679a866020c0e5872fa0
Reviewed-on: http://review.couchbase.org/c/gocb/+/155195
Reviewed-by: Brett Lawson <brett19@gmail.com>
Tested-by: Charles Dixon <chvckd@gmail.com>
  • Loading branch information
chvck committed Jun 9, 2021
1 parent c26c961 commit 7a3e997
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cluster_searchquery.go
Expand Up @@ -61,8 +61,12 @@ type jsonSearchRow struct {
Fields json.RawMessage `json:"fields"`
}

type jsonSearchResponseStatus struct {
Errors map[string]string `json:"errors"`
}

type jsonSearchResponse struct {
Errors map[string]string `json:"errors"`
Status jsonSearchResponseStatus `json:"status,omitempty"`
TotalHits uint64 `json:"total_hits"`
MaxScore float64 `json:"max_score"`
Took uint64 `json:"took"`
Expand Down Expand Up @@ -100,7 +104,7 @@ func (meta *SearchMetaData) fromData(data jsonSearchResponse) error {
}

meta.Metrics = metrics
meta.Errors = data.Errors
meta.Errors = data.Status.Errors

return nil
}
Expand Down

0 comments on commit 7a3e997

Please sign in to comment.