Skip to content
This repository has been archived by the owner on Jun 30, 2018. It is now read-only.

import data gives undefined method `tire' .. error #938

Open
anishshah1210 opened this issue Feb 19, 2014 · 9 comments
Open

import data gives undefined method `tire' .. error #938

anishshah1210 opened this issue Feb 19, 2014 · 9 comments

Comments

@anishshah1210
Copy link

when i run
rake environment tire:import CLASS='Article.all' INDEX='mongo-articles' FORCE=true

gives error
** Invoke environment (first_time)
** Execute environment
** Invoke tire:import (first_time)
** Execute tire:import
[IMPORT] Deleting index 'mongo-articles'
rake aborted!
undefined method tire' for #<Tire::Results::Collection:0xabec954> /home/helios/.rvm/gems/ruby-1.9.3-p484@munksearch/gems/tire-0.5.1/lib /tire/tasks.rb:55:inblock (2 levels) in <top (required)>'
Tasks: TOP => tire:import
I have already tried different version of tire gem like 0.6.0,0.6.2 and 0.5.1

i am completely struck from here

@karmi
Copy link
Owner

karmi commented Feb 19, 2014

I remember the CLASS='Article.all' trick somebody's been using with Mongo, but not the details. Try it with the regular CLASS=Article argument.

@anishshah1210
Copy link
Author

i already tried with
rake environment tire:import CLASS='Article.all'
rake environment tire:import all
rake environment tire:import CLASS='Article'
but error remains same

@anishshah1210
Copy link
Author

when run
rake environment tire:import CLASS='Article'
gives
undefined method `paginate' for Article:Class

@karmi
Copy link
Owner

karmi commented Feb 19, 2014

You're using quite an old version of Tire. Please upgrade and try again.

Also, there's new integration for ActiveModel+Rails at https://github.com/elasticsearch/elasticsearch-rails, I strongly recommend to use it instead of Tire.

@anishshah1210
Copy link
Author

I have already tried different version of tire gem like 0.6.0,0.6.2 and 0.5.1

@anishshah1210
Copy link
Author

can you please suggest me the probable cause of error because I am middle of my development and this doesn't seems feasible idea to move tire gem to something else

@karmi
Copy link
Owner

karmi commented Feb 19, 2014

I'm afraid I can't -- you're running an old version of a retired library, you don't send any information what and how exactly you include Tire modules, ...

Try generating the example application (see README), try playing with the included integration tests for Mongo.

@anishshah1210
Copy link
Author

i tried the example app.
rails new searchapp -m https://raw.github.com/karmi/tire/master/examples/rails-application-template.rb
and put my model code inside
but import gives me the same error .. feel very sad!

my article.rb
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

@anishshah1210
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants