Skip to content

Commit

Permalink
GOCBC-130: Added support for result sorting in FTS.
Browse files Browse the repository at this point in the history
Change-Id: If67de30c5d55727b251796f884c65c940a10bab9
Reviewed-on: http://review.couchbase.org/70826
Reviewed-by: Mark Nunberg <mark.nunberg@couchbase.com>
Tested-by: Brett Lawson <brett19@gmail.com>
  • Loading branch information
brett19 committed Dec 13, 2016
1 parent 696c6f0 commit 27029ba
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions searchquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type searchQueryData struct {
Explain bool `json:"explain,omitempty"`
Highlight *searchQueryHighlightData `json:"highlight,omitempty"`
Fields []string `json:"fields,omitempty"`
Sort []string `json:"sort,omitempty"`
Facets map[string]interface{} `json:"facets,omitempty"`
Ctl *searchQueryCtlData `json:"ctl,omitempty"`
}
Expand Down Expand Up @@ -80,6 +81,12 @@ func (sq *SearchQuery) Fields(fields ...string) *SearchQuery {
return sq
}

// Sort specifies a sorting order for the results. Only available in Couchbase Server 4.6+.
func (sq *SearchQuery) Sort(fields ...string) *SearchQuery {
sq.data.Sort = fields
return sq
}

// AddFacet adds a new search facet to include in the results.
func (sq *SearchQuery) AddFacet(name string, facet interface{}) *SearchQuery {
if sq.data.Facets == nil {
Expand Down

0 comments on commit 27029ba

Please sign in to comment.