繁体   English   中英

ElasticSearch排序

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM