代码之家  ›  专栏  ›  技术社区  ›  Samuel-Zacharie Faure

测试期间太阳黑子重新索引删除开发索引

  •  0
  • Samuel-Zacharie Faure  · 技术社区  · 8 年前

    我正在开发一个搜索API,它使用Sunspot进行索引,使用Rspec进行测试。

      context 'when doing a simple search', :type => :request do
        let!(:instance_of_my_model) { create(:instance_of_my_model) }
        it 'return the correct results' do
          MyModel.reindex
    
         # some test code with a GET request
        end
      end
    

    为了运行测试,我首先启动solr服务器:

    rake sunspot:solr:start RAILS_ENV=test
    

    运行测试后,我停止solr服务器,并在开发环境中再次运行它。搜索不再有效。

    如果我重新索引,它会再次工作:

    rake sunspot:reindex
    

    (自从我有1000多万个条目以来,大约有1个小时)

    有关信息,请参阅my/config/sunspot。yml:

    development:
      solr:
        hostname: localhost
        port: 8982
        log_level: INFO
    
    test:
      solr:
        hostname: localhost
        port: 8981
        log_level: WARNING
    
    1 回复  |  直到 8 年前
        1
  •  1
  •   Samuel-Zacharie Faure    8 年前

    Reindex on sunspot rails 给了我小费。

    我的太阳黑子。yml应该是:

    development:
      solr:
        hostname: localhost
        port: 8982
        log_level: INFO
        path: /solr/development
    
    
    test:
      solr:
        hostname: localhost
        port: 8981
        log_level: WARNING
        path: /solr/test