2

我的数据库有超过 300 万份文档需要编制索引。这是我的设置:

Heroku 上的 Rails 4.2.0beta2。将SearchkickFound Heroku 插件一起使用。

这些是我索引的模型:

class Item
 searchkick text_start: [:n, :ot, :est]

 def search_data
        # as_json only: [:n, :ot, :est, :dst, :d, :a]
        {
            n: n,
            ot: detail.ot,
            est: detail.est,
            dst: dst,
            d: detail.d,
            a: detail.a
        }
 end

结尾

class User
     searchkick text_start: [:full_name]

     def full_name
         "#{first_name} #{last_name}"
     end

     def search_data
        {
            full_name: full_name
        }
     end
 end

.. 通过做rake searchkick:reindex:all.

现在,我注意到我们的 Elasticsearch 集群只索引了我一半的文档(约 150 万)。我询问了我们的集群提供商是否对文档数量有任何限制,并确认没有。我不知道为什么它停在 150 万(而不是索引所有 300 万)。但是,现在我正在尝试再次索引所有内容并注意错误或类似情况,这是它出现的第一件事(在索引任何内容之前):

NameError: undefined local variable or method `index' for #<Searchkick::Index:0x007fbb5308bf18>
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/searchkick-0.8.6/lib/searchkick/index.rb:192:in `block in import_scope'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/mongoid-4.0.1/lib/mongoid/contextual/mongo.rb:648:in `yield_document'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/mongoid-4.0.1/lib/mongoid/contextual/mongo.rb:123:in `block in each'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/moped-2.0.3/lib/moped/cursor.rb:32:in `block in each'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/moped-2.0.3/lib/moped/cursor.rb:32:in `each'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/moped-2.0.3/lib/moped/cursor.rb:32:in `each'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/moped-2.0.3/lib/moped/query.rb:77:in `each'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/mongoid-4.0.1/lib/mongoid/contextual/mongo.rb:122:in `each'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/mongoid-4.0.1/lib/mongoid/contextual.rb:20:in `each'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/searchkick-0.8.6/lib/searchkick/index.rb:189:in `import_scope'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/searchkick-0.8.6/lib/searchkick/index.rb:158:in `reindex_scope'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/searchkick-0.8.6/lib/searchkick/model.rb:47:in `reindex'
    from (irb):1
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/console.rb:110:in `start'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/console.rb:9:in `start'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:68:in `console'
... 7 levels...
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.3.1/lib/spring/commands/rails.rb:6:in `call'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.3.1/lib/spring/command_wrapper.rb:38:in `call'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.3.1/lib/spring/application.rb:183:in `block in serve'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.3.1/lib/spring/application.rb:156:in `fork'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.3.1/lib/spring/application.rb:156:in `serve'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.3.1/lib/spring/application.rb:131:in `block in run'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.3.1/lib/spring/application.rb:125:in `loop'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.3.1/lib/spring/application.rb:125:in `run'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/spring-1.3.1/lib/spring/application/boot.rb:18:in `<top (required)>'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/borjagvo/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'

出现此错误后检查集群状态,我看到创建了一个新索引而不是“覆盖”旧索引:http ://cl.ly/image/0I0v1a2T1N2W

我做错了什么?关于如何解决这个问题的任何想法?

提前致谢。

4

0 回答 0