[英]ElasticSearch sorting
ElasticSearch版本:1.3.2
我正在嘗試對簡單集合進行排序,但是無論我嘗試什么,都只是忽略了對我的排序...
{
"query":{
"filtered":{
"query":{
"match_all":{
}
},
"filter":{
"bool":{
"must":[
{
"terms":{
"status":[
"active",
"featured"
]
}
}
]
}
}
}
},
"sort":[
{
"price_cents":{
"order":"asc"
}
}
]
}
我在映射中注意到我有auto_boost = true
{
"items" : {
"mappings" : {
"item" : {
"dynamic" : "false",
"_all" : {
"auto_boost" : true
},
"properties" : {
"price_cents" : {
"type" : "integer"
},
"status" : {
"type" : "string"
},
"title" : {
"type" : "string",
"boost" : 10.0,
"analyzer" : "snowball"
}
}
}
}
}
}
我使用的https://github.com/elasticsearch/elasticsearch-rails gem自動添加了此屬性:
mappings :dynamic => false do
indexes :title, :analyzer => 'snowball', :boost => 10.0
indexes :status
indexes :price_cents, :type => :integer, :index => 'not_analyzed'
end
我不知道是“ auto_boost”:排序的真實原因忽略了嗎? 我找不到正確的方法將其設置為false並檢查...
我發現了問題,它與.records( https://github.com/elasticsearch/elasticsearch-rails/issues/206 )的當前錯誤有關,因為它無法正確分頁,因此我臨時使用了這種結構@paginates_items = Item.search(params).page(params[:page]).per(60).results item_ids = @paginates_items.collect(&:id) @items = Item.where(:id => item_ids)
但是我忘記了where(:id => items_id)完全破壞了訂單...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.