0
0
Fork 0

avoid crash when requesting more facets then available

This commit is contained in:
Marty Schoch 2015-01-22 09:56:00 -05:00
parent 944fae27f0
commit e59ed148c9
1 changed files with 5 additions and 1 deletions

View File

@ -70,7 +70,11 @@ func (fb *TermsFacetBuilder) Result() *search.FacetResult {
sort.Sort(rv.Terms)
// we now have the list of the top N facets
rv.Terms = rv.Terms[:fb.size]
trimTopN := fb.size
if trimTopN > len(rv.Terms) {
trimTopN = len(rv.Terms)
}
rv.Terms = rv.Terms[:trimTopN]
notOther := 0
for _, tf := range rv.Terms {