I have a CSV file (2.5MB) and I get an error when I want to reindex:
// console
[2] pry(main)> Thema.reindex
Faraday::TimeoutError: Net::ReadTimeout
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/net/protocol.rb:158:in `rbuf_fill'
// thema.rb
searchkick match: :word_start,
searchable: [:titel, :einleitung],
language: "german",
suggest: [:titel, :einleitung],
highlight: [:titel],
misspellings: {edit_distance: 3},
synonyms: -> { CSV.read('vendor/assets/csv/openthesaurus.csv') }
// openthesaurus.csv
Kernspaltung,Atomspaltung,Kernfission,Fission
Fortf眉hrung,Wiederaufnahme
abfliegen,wegfliegen,abreisen, fortfahren,davonfahren,wegfahren,aufbrechen,abfahren,abd眉sen
... (35000 lines)
I found a workaround
// initializers/searchkick.rb
if Rails.env.development?
Searchkick.client =
Elasticsearch::Client.new(
url: '127.0.0.1:9200',
transport_options: {request: {timeout: 200}}
)
end
The default timeout was too short.
Is there a better way?
Having a large set of synonyms will significantly increase indexing time - no way around that. You can increase the timeout as you did - Searchkick.timeout = 200 - or decrease the batch_size.
Most helpful comment
Having a large set of synonyms will significantly increase indexing time - no way around that. You can increase the timeout as you did -
Searchkick.timeout = 200- or decrease thebatch_size.