Elasticsearchで(Tire gemを介して)添付ファイルのインデックスを作成していますが、かなり大きいです。なんらかの理由で、私はこれを予期していなかったので、検索は非常に遅いです。Tire_source
(ES)が検索結果にドキュメント全体を含めているためと思われます。これは不要ですが、オフにする方法がわかりません。
ESと直接通信する場合は、ESpartial_fields
を制限する要素を含めることができます。
"partial_fields" : {
"no_PDFs" : {
"exclude" : ["attachment", "reports.attachment"]
}
}
タイヤ検索から要素を除外する方法を知っている人はいますか?
class Report < ActiveRecord::Base
include Tire::Model::Search
include Tire::Model::Callbacks
...
tire.mapping do
indexes :id, :type =>'integer'
indexes :title
indexes :attachment, :type => 'attachment',
:fields => {
:author => { :store => 'yes' },
:attachment => { :term_vector => 'with_positions_offsets', :store => 'yes' },
:date => { :store => 'yes' }
}
end
def self.search(params)
tire.search do
query { string params[:query] } if params[:query].present?
highlight :attachment
end
end
...