2013-06-27 82 views
0

我有一個Profile類。在ES索引中我有company_type屬性。如何增強查詢取決於ElasticSearch中的屬性值?

class Profile 
    ... 
    include Tire::Model::Search 
    include Tire::Model::Callbacks 

    def to_indexed_json 
    { name: self.name, 
     company_type: self.company.company_type 
    }.to_json 
    end 
end 

Tire.search('profiles') do 
    query do 
    custom_filters_score do 
     query { all } 

     filter do 
     filter :range, last_contact_at: { gte: 7.days.ago } 
     boost 1 
     end 

     score_mode :total 
    end 
    end 
end.results 

我想如果company_type == 'intern'10查詢提振。

回答

1

做你嘗試加入

filter do 
    filter :term, company_type: "intern" 
    boost 10.0 
end 

custom_filters_score過濾器?

相關問題