0

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
  ...
4

1 に答える 1

2

partial_fieldsタイヤでの直接サポートはまだありません。

fields検索方法のオプションを使用して、応答を制限します。

require 'tire'

Tire.index 'bigfields-test' do
  delete and create

  store title: 'Test 1', content: 'x'*100_000
  store title: 'Test 2', content: 'x'*100_000

  refresh
end

s = Tire.search 'bigfields-test', fields: 'title' do
  query { string 'test' }
end

p s.results
于 2012-09-23T07:34:14.383 に答える