0
0
Fork 0

search request JSON omitting size, now defaults to 10

this change only affects JSON parsing, any search request which
omits the size field entirely now defaults to 10 which
is the same behavior as NewSearchRequest()

0 is still a valid size, but must be set explicitly
This commit is contained in:
Marty Schoch 2016-03-31 09:56:06 -04:00
parent 2b82387eae
commit d774f980d3
1 changed files with 6 additions and 2 deletions

View File

@ -182,7 +182,7 @@ func (r *SearchRequest) AddFacet(facetName string, f *FacetRequest) {
func (r *SearchRequest) UnmarshalJSON(input []byte) error {
var temp struct {
Q json.RawMessage `json:"query"`
Size int `json:"size"`
Size *int `json:"size"`
From int `json:"from"`
Highlight *HighlightRequest `json:"highlight"`
Fields []string `json:"fields"`
@ -195,7 +195,11 @@ func (r *SearchRequest) UnmarshalJSON(input []byte) error {
return err
}
r.Size = temp.Size
if temp.Size == nil {
r.Size = 10
} else {
r.Size = *temp.Size
}
r.From = temp.From
r.Explain = temp.Explain
r.Highlight = temp.Highlight