retire
retire copied to clipboard
import data to ES gives error
when I run this command rake environment tire:import CLASS=Article FORCE=true i got error [IMPORT] Importing 'Article' rake aborted! undefined method `paginate' for Article:Class
My article.rb
class Article
MIN_TERM_CHARS = 2
MAX_NGRAM_CHARS = 20
include SyncAttr
include Tire::Model::Persistence
# TODO: maybe we want to swap synonym and stop word filters.
# TODO: maybe we want to swap asciifolding and lowercase filters.
# TODO: maybe we want to disable _all field and set default query field.
# TODO: we could disable the storing of _source JSON. or compress it.
settings \
analysis: {
analyzer: {
"default" => {
"type" => "custom",
"tokenizer" => "standard",
"filter" => ["standard", "asciifolding", "lowercase", "munk_length", "munk_decompounder", "munk_stop", "munk_synonym"]
},
"ngram_index_analyzer" => {
"type" => "custom",
"tokenizer" => "standard",
"filter" => ["standard", "asciifolding", "lowercase", "munk_length", "munk_decompounder", "munk_stop", "munk_synonym", "ngram_filter"]
},
"ngram_search_analyzer" => {
"type" => "custom",
"tokenizer" => "standard",
"filter" => ["standard", "asciifolding", "lowercase", "munk_length", "munk_decompounder", "munk_stop", "munk_synonym"]
},
"hierarchie_index_analyzer" => {
"type" => "custom",
"tokenizer" => "hierarchie_tokenizer"
},
"suggest_analyzer" => {
"type" => "custom",
"tokenizer" => "standard",
# no asciifolding here because we want to autocomplete the actual query of the user. lowercase is necessary
# though because of inconsistent writing in article data as well as query strings.
# if we add stopwords then we probably want to set "enable_position_increments": "false".
# see http://getelastomer.com/blog/2013/01/searching-with-shingles/#.URAThFrjmoo
#
"filter" => ["standard", "lowercase", "suggest_shingle"]
}
},
tokenizer: {
"hierarchie_tokenizer" => {
"type" => "path_hierarchy",
"delimiter" => "|",
}
},
filter: {
"munk_decompounder" => {
"type" => "dictionary_decompounder",
"word_list_path" => Rails.root.join("config", "es", "munk_compound_words.txt").to_s,
},
"munk_stop" => {
"type" => "stop",
"stopwords_path" => Rails.root.join("config", "es", "munk_stop_words.txt").to_s,
},
"munk_synonym" => {
"type" => "synonym",
"synonyms_path" => Rails.root.join("config", "es", "munk_synonym_words.txt").to_s,
"expand" => true # we want to expand terms because of compound words
},
"munk_length" => {
"type" => "length",
"min" => MIN_TERM_CHARS, # require at least 2 chars. 2 is better than 3 here because of abbreviations.
},
"ngram_filter" => {
"type" => "nGram",
"min_gram" => MIN_TERM_CHARS, # start ngrams with 3 chars. 2 chars are expensive and not neccessary
"max_gram" => MAX_NGRAM_CHARS # TODO: longest search word?
},
"suggest_shingle" => {
"type" => "shingle",
"min_shingle_size" => 2,
"max_shingle_size" => 3
}
}
}
# TODO: default index name
index_name { Thread.current[:index_name] || "test" }
document_type "document"
# TODO: set index_options to doc for some fields for optimization
# TODO: maybe use simple analyzer for 'id' fieldsart
property :artikelnummer, type: 'string', index: 'not_analyzed'
property :eannummer, type: 'string', index: 'not_analyzed'
property :bezeichnung, type: 'multi_field', fields: {
bezeichnung: {type: 'string'},
ngram: {:type => 'string', :index_analyzer => 'ngram_index_analyzer', :search_analyzer => 'ngram_search_analyzer'},
suggest: {:type => 'string', :analyzer => 'suggest_analyzer'}
}
property :bezeichnung_zusatz, type: 'multi_field', fields: {
bezeichnung_zusatz: {type: 'string'},
ngram: {:type => 'string', :index_analyzer => 'ngram_index_analyzer', :search_analyzer => 'ngram_search_analyzer'}
}
property :matchcode, type: 'string', index: 'not_analyzed'
property :mengeneinheit, type: 'string', include_in_all: false
property :gewicht, type: 'float', include_in_all: false
property :hersteller, type: 'multi_field', fields: {
hersteller: {type: 'string'},
unchanged: {type: 'string', :index => 'not_analyzed'},
ngram: {:type => 'string', :index_analyzer => 'ngram_index_analyzer', :search_analyzer => 'ngram_search_analyzer'}
}
property :hersteller_nummer, type: 'string', index: 'not_analyzed', include_in_all: false
property :hersteller_artikelnummer, type: 'string', index: 'not_analyzed'
property :gruppe, type: 'multi_field', fields: {
gruppe: {type: 'string'},
ngram: {:type => 'string', :index_analyzer => 'ngram_index_analyzer', :search_analyzer => 'ngram_search_analyzer'}
}
property :gruppe_zusatz, type: 'multi_field', fields: {
gruppe_zusatz: {type: 'string'},
ngram: {:type => 'string', :index_analyzer => 'ngram_index_analyzer', :search_analyzer => 'ngram_search_analyzer'}
}
property :gruppe_nummer, type: 'string', index: 'not_analyzed', include_in_all: false
#property :hauptgruppe, type: 'multi_field', fields: {
# hauptgruppe: {type: 'string'},
# ngram: {:type => 'string', :index_analyzer => 'ngram_index_analyzer', :search_analyzer => 'ngram_search_analyzer'}
#}
# TODO: n-level facet
property :hierarchie, type: 'multi_field', fields: {
hierarchie: {type: 'string', index_analyzer: 'hierarchie_index_analyzer', search_analyzer: 'keyword', include_in_all: false},
ngram: {type: 'string', index_analyzer: 'ngram_index_analyzer', search_analyzer: 'ngram_search_analyzer'}
}
property :langtext, type: 'multi_field', fields: {
langtext: {type: 'string'},
ngram: {:type => 'string', :index_analyzer => 'ngram_index_analyzer', :search_analyzer => 'ngram_search_analyzer'}
}
property :infotext, type: 'multi_field', fields: {
infotext: {type: 'string'},
ngram: {:type => 'string', :index_analyzer => 'ngram_index_analyzer', :search_analyzer => 'ngram_search_analyzer'}
}
property :bestelltext, type: 'multi_field', fields: {
bestelltext: {type: 'string'},
ngram: {:type => 'string', :index_analyzer => 'ngram_index_analyzer', :search_analyzer => 'ngram_search_analyzer'}
}
property :dimension, type: 'string', include_in_all: false
property :listenpreis_netto, type: 'float', index: 'not_analyzed', include_in_all: false
property :listenpreis_brutto, type: 'float', index: 'not_analyzed', include_in_all: false
validates_presence_of :artikelnummer
validates_presence_of :bezeichnung
# TODO: enable later
#validates_presence_of :gruppe
#validates_presence_of :hauptgruppe
def self.set_current_index_name(name)
Thread.current[:index_name] = name
end
end
a) Run the Rake task with --trace
to see the whole backtrace
b) Do you include will_paginate
or kaminari
in your Gemfile?
yes i have will_paginate in my gem file
when i run it with the trace
Invoke environment (first_time)
** Execute environment
** Invoke tire:import:model (first_time)
** Execute tire:import:model
[IMPORT] Importing 'Article'
rake aborted!
undefined method paginate' for Article:Class /home/helios/.rvm/gems/ruby-1.9.3-p484/gems/tire-0.6.2/lib/tire/index.rb:288:in
import'
/home/helios/.rvm/gems/ruby-1.9.3-p484/gems/tire-0.6.2/lib/tire/model/import.rb:115:in import' /home/helios/.rvm/gems/ruby-1.9.3-p484/gems/tire-0.6.2/lib/tire/model/import.rb:22:in
import'
/home/helios/.rvm/gems/ruby-1.9.3-p484/gems/tire-0.6.2/lib/tire/tasks.rb:49:in import_model' /home/helios/.rvm/gems/ruby-1.9.3-p484/gems/tire-0.6.2/lib/tire/tasks.rb:112:in
block (3 levels) in <top (required)>'
/home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/rake-10.1.1/lib/rake/task.rb:236:in call' /home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/rake-10.1.1/lib/rake/task.rb:236:in
block in execute'
/home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/rake-10.1.1/lib/rake/task.rb:231:in each' /home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/rake-10.1.1/lib/rake/task.rb:231:in
execute'
/home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/rake-10.1.1/lib/rake/task.rb:175:in block in invoke_with_call_chain' /home/helios/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/monitor.rb:211:in
mon_synchronize'
/home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/rake-10.1.1/lib/rake/task.rb:168:in invoke_with_call_chain' /home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/rake-10.1.1/lib/rake/task.rb:161:in
invoke'
/home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/rake-10.1.1/lib/rake/application.rb:149:in invoke_task' /home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/rake-10.1.1/lib/rake/application.rb:106:in
block (2 levels) in top_level'
/home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/rake-10.1.1/lib/rake/application.rb:106:in each' /home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/rake-10.1.1/lib/rake/application.rb:106:in
block in top_level'
/home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/rake-10.1.1/lib/rake/application.rb:115:in run_with_threads' /home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/rake-10.1.1/lib/rake/application.rb:100:in
top_level'
/home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/rake-10.1.1/lib/rake/application.rb:78:in block in run' /home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/rake-10.1.1/lib/rake/application.rb:165:in
standard_exception_handling'
/home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/rake-10.1.1/lib/rake/application.rb:75:in run' /home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/rake-10.1.1/bin/rake:33:in
<top (required)>'
/home/helios/.rvm/gems/ruby-1.9.3-p484/bin/rake:23:in load' /home/helios/.rvm/gems/ruby-1.9.3-p484/bin/rake:23:in
eval' /home/helios/.rvm/gems/ruby-1.9.3-p484/bin/ruby_executable_hooks:15:in
above error occure
So, what are you importing when your Article is Tire::Model::Persistence
, not e.g. ActiveRecord::Base
?
that specify in my article.rb as in my first comment in lines 93 to 165
My console says helios@HS021:~/paragbhai_pro/dynalink$ rake environment tire:import:model CLASS='Article' FORCE=1 /home/helios/.rvm/gems/ruby-1.9.3-p484@global/gems/bundler-1.5.2/lib/bundler.rb:295: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777 [IMPORT] Deleting index 'test' [IMPORT] Creating index 'test' with mapping: {"document":{"properties":{"artikelnummer":{"type":"string","index":"not_analyzed"},"eannummer":{"type":"string","index":"not_analyzed"},"bezeichnung":{"type":"multi_field","fields":{"bezeichnung":{"type":"string"},"ngram":{"type":"string","index_analyzer":"ngram_index_analyzer","search_analyzer":"ngram_search_analyzer"},"suggest":{"type":"string","analyzer":"suggest_analyzer"}}},"bezeichnung_zusatz":{"type":"multi_field","fields":{"bezeichnung_zusatz":{"type":"string"},"ngram":{"type":"string","index_analyzer":"ngram_index_analyzer","search_analyzer":"ngram_search_analyzer"}}},"matchcode":{"type":"string","index":"not_analyzed"},"mengeneinheit":{"type":"string","include_in_all":false},"gewicht":{"type":"float","include_in_all":false},"hersteller":{"type":"multi_field","fields":{"hersteller":{"type":"string"},"unchanged":{"type":"string","index":"not_analyzed"},"ngram":{"type":"string","index_analyzer":"ngram_index_analyzer","search_analyzer":"ngram_search_analyzer"}}},"hersteller_nummer":{"type":"string","index":"not_analyzed","include_in_all":false},"hersteller_artikelnummer":{"type":"string","index":"not_analyzed"},"gruppe":{"type":"multi_field","fields":{"gruppe":{"type":"string"},"ngram":{"type":"string","index_analyzer":"ngram_index_analyzer","search_analyzer":"ngram_search_analyzer"}}},"gruppe_zusatz":{"type":"multi_field","fields":{"gruppe_zusatz":{"type":"string"},"ngram":{"type":"string","index_analyzer":"ngram_index_analyzer","search_analyzer":"ngram_search_analyzer"}}},"gruppe_nummer":{"type":"string","index":"not_analyzed","include_in_all":false},"hierarchie":{"type":"multi_field","fields":{"hierarchie":{"type":"string","index_analyzer":"hierarchie_index_analyzer","search_analyzer":"keyword","include_in_all":false},"ngram":{"type":"string","index_analyzer":"ngram_index_analyzer","search_analyzer":"ngram_search_analyzer"}}},"langtext":{"type":"multi_field","fields":{"langtext":{"type":"string"},"ngram":{"type":"string","index_analyzer":"ngram_index_analyzer","search_analyzer":"ngram_search_analyzer"}}},"infotext":{"type":"multi_field","fields":{"infotext":{"type":"string"},"ngram":{"type":"string","index_analyzer":"ngram_index_analyzer","search_analyzer":"ngram_search_analyzer"}}},"bestelltext":{"type":"multi_field","fields":{"bestelltext":{"type":"string"},"ngram":{"type":"string","index_analyzer":"ngram_index_analyzer","search_analyzer":"ngram_search_analyzer"}}},"dimension":{"type":"string","include_in_all":false},"listenpreis_netto":{"type":"float","index":"not_analyzed","include_in_all":false},"listenpreis_brutto":{"type":"float","index":"not_analyzed","include_in_all":false}}}} [IMPORT] Importing 'Article' rake aborted! undefined method `paginate' for Article:Class