0
0
Fork 0

fix SearchRequest parsing to default to proper default sort order

This commit is contained in:
Marty Schoch 2016-08-12 14:49:22 -04:00
parent 0bb69a9a1c
commit be56380833
1 changed files with 4 additions and 0 deletions

View File

@ -238,6 +238,7 @@ func (r *SearchRequest) UnmarshalJSON(input []byte) error {
Fields []string `json:"fields"`
Facets FacetsRequest `json:"facets"`
Explain bool `json:"explain"`
Sort search.SortOrder `json:"sort"`
}
err := json.Unmarshal(input, &temp)
@ -250,6 +251,9 @@ func (r *SearchRequest) UnmarshalJSON(input []byte) error {
} else {
r.Size = *temp.Size
}
if temp.Sort == nil {
r.Sort = search.SortOrder{&search.SortScore{Descending: true}}
}
r.From = temp.From
r.Explain = temp.Explain
r.Highlight = temp.Highlight