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

import data to ES gives error #945

Open
anishshah1210 opened this issue Feb 26, 2014 · 5 comments
Open

import data to ES gives error #945

anishshah1210 opened this issue Feb 26, 2014 · 5 comments

Comments

@anishshah1210
Copy link

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
@karmi
Copy link
Owner

karmi commented Feb 26, 2014

a) Run the Rake task with --trace to see the whole backtrace
b) Do you include will_paginate or kaminari in your Gemfile?

@anishshah1210
Copy link
Author

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:inimport'
/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:inimport'
/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:inblock (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:inblock 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:inexecute'
/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:inmon_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:ininvoke'
/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:inblock (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:inblock 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:intop_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:instandard_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

'
/home/helios/.rvm/gems/ruby-1.9.3-p484/bin/ruby_executable_hooks:15:in eval' /home/helios/.rvm/gems/ruby-1.9.3-p484/bin/ruby_executable_hooks:15:in'
Tasks: TOP => tire:import:model

above error occure

@karmi
Copy link
Owner

karmi commented Feb 26, 2014

So, what are you importing when your Article is Tire::Model::Persistence, not e.g. ActiveRecord::Base?

@anishshah1210
Copy link
Author

that specify in my article.rb as in my first comment
in lines
93 to 165

@anishshah1210
Copy link
Author

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

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