diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2020-09-07 06:51:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-06 18:51:14 -0400 |
commit | d17efaa1146bf0ec9a52b004e6d79f971253b1a2 (patch) | |
tree | 23b05001ad7b32f170b63f63a2c5509a517aec51 /vendor/github.com/blevesearch/bleve/search.go | |
parent | 1b9d5074a7ebb1b470f468cc9195d54915291ee3 (diff) | |
download | gitea-d17efaa1146bf0ec9a52b004e6d79f971253b1a2.tar.gz gitea-d17efaa1146bf0ec9a52b004e6d79f971253b1a2.zip |
Upgrade bleve to v1.0.10 (#12737)
* Fix bug on migration 111
* Upgrade bleve to 1.0.10
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'vendor/github.com/blevesearch/bleve/search.go')
-rw-r--r-- | vendor/github.com/blevesearch/bleve/search.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/vendor/github.com/blevesearch/bleve/search.go b/vendor/github.com/blevesearch/bleve/search.go index b337edc9e4..f67450779a 100644 --- a/vendor/github.com/blevesearch/bleve/search.go +++ b/vendor/github.com/blevesearch/bleve/search.go @@ -18,6 +18,7 @@ import ( "encoding/json" "fmt" "reflect" + "sort" "time" "github.com/blevesearch/bleve/analysis" @@ -264,6 +265,7 @@ func (h *HighlightRequest) AddField(field string) { // Score controls the kind of scoring performed // SearchAfter supports deep paging by providing a minimum sort key // SearchBefore supports deep paging by providing a maximum sort key +// sortFunc specifies the sort implementation to use for sorting results. // // A special field named "*" can be used to return all fields. type SearchRequest struct { @@ -279,6 +281,8 @@ type SearchRequest struct { Score string `json:"score,omitempty"` SearchAfter []string `json:"search_after"` SearchBefore []string `json:"search_before"` + + sortFunc func(sort.Interface) } func (r *SearchRequest) Validate() error { @@ -606,3 +610,22 @@ func MemoryNeededForSearchResult(req *SearchRequest) uint64 { return uint64(estimate) } + +// SetSortFunc sets the sort implementation to use when sorting hits. +// +// SearchRequests can specify a custom sort implementation to meet +// their needs. For instance, by specifying a parallel sort +// that uses all available cores. +func (r *SearchRequest) SetSortFunc(s func(sort.Interface)) { + r.sortFunc = s +} + +// SortFunc returns the sort implementation to use when sorting hits. +// Defaults to sort.Sort. +func (r *SearchRequest) SortFunc() func(data sort.Interface) { + if r.sortFunc != nil { + return r.sortFunc + } + + return sort.Sort +} |