2012-08-16 83 views
0

使用ajaxsolr和瀏覽器兼容性排序問題。思考最好的辦法是關閉solr排序並進行客戶端控制。下面是創建對象數組的代碼和我的反向排序愚蠢的嘗試:在ajaxsolr中反向排序

getFacetCountsMap: function (property) { 
    var counts = []; 
    for (var facet in this.manager.response.facet_counts[property] [this.field]) { 
     counts.push({ 
      facet: facet, 
      count:parseInt(this.manager.response.facet_counts[property][this.field][facet]) 
     }); 
    } 
    return counts; 
} 

我更換的迴歸計數;與以下內容:

counts:counts.sort(function(a, b){ 
return b.count-a.count; 
    }); 
return counts; 
}, 

沒有錯誤信息,但沒有排序。我是否在場上或甚至沒有在比賽中?

回答

0

您的代碼可能無法在IE

counts = counts.sort(function(a, b){ 
    return (b.count - a.count) >0 ? 1 : -1 ; 
}); 

的工作,你最好使用1 & -1

+0

排序順序不反轉在任一情況下:•配方(1) •圖像(2) •培訓材料(39) •全文(532) •項目數據(1140) •引文(136675) – 2012-08-16 13:55:18

0

應設置facet.sort Solr的參數,而不是做這個客戶端的。