Skip to content

Commit

Permalink
Open SearchRequest.Body for read-only access
Browse files Browse the repository at this point in the history
This commit opens access to the SearchRequest body generated by the DSL.

Fix #548
  • Loading branch information
olivere committed Oct 14, 2017
1 parent c73f8b3 commit e8c9fc5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion 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 = "5.0.50"
Version = "5.0.51"

// 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
2 changes: 1 addition & 1 deletion msearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (s *MultiSearchService) Do(ctx context.Context) (*MultiSearchResult, error)
if err != nil {
return nil, err
}
body, err := json.Marshal(sr.body())
body, err := json.Marshal(sr.Body())
if err != nil {
return nil, err
}
Expand Down
9 changes: 6 additions & 3 deletions search_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,12 @@ func (r *SearchRequest) header() interface{} {
return h
}

// body is used by MultiSearch to get information about the search body
// Body allows to access the search body of the request, as generated by the DSL.
// Notice that Body is read-only. You must not change the request body.
//
// Body is used e.g. by MultiSearch to get information about the search body
// of one SearchRequest.
// See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-multi-search.html
func (r *SearchRequest) body() interface{} {
// See https://www.elastic.co/guide/en/elasticsearch/reference/5.6/search-multi-search.html
func (r *SearchRequest) Body() interface{} {
return r.source
}

0 comments on commit e8c9fc5

Please sign in to comment.